Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HubitatDevicesService

A service responsible for Hubitat's device management. The service allows for an up-to-date access to devices and their status, requesting device updates and routing device events to registered automations. It maintains a cache of Hubitat's devices and keeps them up to date by listening to device update events and by polling all devices from Hubitat periodically.

param
param

Hierarchy

  • HubitatDevicesService

Index

Constructors

constructor

Methods

announceAttributeUpdate

  • announceAttributeUpdate(attributeName: string, device: HubitatDevice, newValue: string | null, previousValue: string | null | undefined): void

getAllDevices

getDevice

hasDevice

  • hasDevice(deviceId: number): boolean
  • Returns a value whether there is a device with specified ID in the service's cache.

    Parameters

    • deviceId: number

      The ID of the device.

    Returns boolean

    true if there is a matching device in the cache; false if there is no such device in the cache.

reloadAllDevices

reloadDevice

  • reloadDevice(deviceId: number): Promise<HubitatDevice | undefined>

Static getDevice

  • A static function allowing for singleton-style device querying. Helps to simplify automations code. Returns undefined if there's no such device. This function won't send any requests to the Hubitat's Maker API as it fetches the device from the cache.

    example
    const device = HubitatDevicesService.getDevice(78);
    if (device != null)
      console.log(`Device name is: ${device.name}`);

    Parameters

    • deviceId: number

      Id of the requested device.

    Returns HubitatDevice | undefined

    Returns a device matching the provided ID or undefined if there is no such device.

Generated using TypeDoc