Options
All
  • Public
  • Public/Protected
  • All
Menu

A Hubitat device event. It represents a single attribute value change in a Hubitat device.

Hierarchy

Index

Constructors

constructor

  • new HubitatDeviceEvent(attributeName: string, device: HubitatDevice, deviceId: number, newValue: string | null, previousValue: string | null | undefined): HubitatDeviceEvent
  • Creates a new event instance.

    Parameters

    • attributeName: string

      A name of the attribute which value has changed.

    • device: HubitatDevice

      A reference to the updated device.

    • deviceId: number

      An id of the changed device.

    • newValue: string | null

      A new value of the specified attribute.

    • previousValue: string | null | undefined

      A value of the specified attribute before the change appeared.

    Returns HubitatDeviceEvent

Properties

Readonly attributeName

attributeName: string

A name of the attribute which value has changed.

Readonly device

A reference to the updated device.

Readonly deviceId

deviceId: number

An id of the changed device.

Readonly eventType

eventType: "hubitat-device" = HUBITAT_DEVICE_EVENT_TYPE

A string value describing the hubitat device event type.

Readonly newValue

newValue: string | null

A new value of the specified attribute.

Readonly previousValue

previousValue: string | null | undefined

A value of the specified attribute before the change appeared.

Methods

handleAs

  • handleAs<T>(eventClass: Constructor<T>): T
  • Force-cast the event as specified type.

    example

    Can be used to identify the type of the event in an automation:

    async handleEvent(event: AutomationEvent) {
      try {
        const timerEvent = event.handleAs(TimerEvent);
      } catch (e) {
        // ...
      }
    }
    throws

    Throws an error if the cast failed.

    Type parameters

    Parameters

    • eventClass: Constructor<T>

      An AutomationEvent subclass to cast this event to.

    Returns T

    An event casted to a type specified in eventClass argument.

Generated using TypeDoc