Heatzy API for Node.js - v21.3.1
    Preparing search index...

    Class DeviceRegistry

    Central in-memory registry of all bound Heatzy devices. Synced from the /bindings + /devdata responses and queryable by id.

    Upsert + prune semantics: an existing model is updated in place, a new one created, a stale entry removed. Object identity therefore survives an UPSERT and not a PRUNE — an id that leaves the listing is deleted, and its next appearance is a different object. Facades bind by id for exactly that reason; they must never hold the entity.

    Index
    • Builds the registry.

      Parameters

      • options: { timezone?: string } = {}

        Options bag.

        • Optionaltimezone?: string

          IANA timezone threaded into every Device for derogation end dates; defaults to the runtime system timezone.

      Returns DeviceRegistry

    devices: { getById: (id: string) => Device | undefined } = ...

    Type Declaration

    • getById: (id: string) => Device | undefined

      Returns the device with the given id, or undefined when no such device is registered.

    • Upserts the device registry from fresh wire data; entries absent from bindings are pruned. A binding whose attributes are missing from attributes keeps its existing model untouched (stale data beats no data) and is skipped when new — the tolerance HeatzyAPI's /devdata fan-out feeds, one settled leg per device, so a device that answered /bindings but not /devdata costs itself and no sibling.

      Every binding is expected to be one this SDK models: Device resolves its product_key in its constructor and THROWS on a key this SDK predates. The listing boundary (HeatzyAPI.list) is what guarantees that; a caller synchronizing hand-built bindings owns the same precondition.

      Parameters

      • bindings: readonly DeviceBinding[]

        Fresh /bindings entries this SDK models.

      • attributes: Readonly<Record<string, Attributes>>

        Live attribute payloads keyed by did.

      Returns void