Options
All
  • Public
  • Public/Protected
  • All
Menu

A representation of a Hubitat's device.

Hierarchy

  • HubitatDevice

Index

Constructors

constructor

Properties

Readonly id

id: number

A unique id of the device.

label

label: string

A label of the device.

name

name: string

A name of the device.

Methods

getAttribute

  • getAttribute(attributeName: string): string | null | undefined
  • Returns a value of an attribute with specified name.

    Parameters

    • attributeName: string

      The name of the attribute.

    Returns string | null | undefined

    Returns a value of an attribute or undefined if there is no such attribute.

getAttributeAsFloat

  • getAttributeAsFloat(name: string): number
  • Gets a value of the attribute as a floating point number.

    Parameters

    • name: string

      Name of the attribute.

    Returns number

    Returns a value of the attribute as a floating number. Returns 0 if there's no such attribute or its value is not parsable.

getAttributeAsInt

  • getAttributeAsInt(name: string): number
  • Gets a value of the attribute as an integer.

    Parameters

    • name: string

      Name of the attribute.

    Returns number

    Returns a value of the attribute as an integer. Returns 0 if there's no such attribute or its value is not parsable.

getAttributeAsString

  • getAttributeAsString(name: string): string | undefined
  • Gets a value of the attribute as a string.

    Parameters

    • name: string

      Name of the attribute.

    Returns string | undefined

    Gets a value of the attribute as a string. Returns undefined if there's no such attribute or its value is empty.

getAttributes

  • getAttributes(): { attributeName: string; attributeValue: string | null }[]
  • Returns a list of all attribute names and their values.

    Returns { attributeName: string; attributeValue: string | null }[]

    Returns a list of all attribute names and their values. The list can be empty.

hasAttribute

  • hasAttribute(attributeName: string): boolean
  • Returns a value whether the device contains an attribute with the specified name.

    Parameters

    • attributeName: string

      The name of the attribute.

    Returns boolean

    true if the device has the attribute; false if the device doesn't have the attribute.

hasCapabilities

  • hasCapabilities(capabilities: Iterable<ECapability>): boolean
  • Returns a value whether the device contains all of the specified capabilities.

    Parameters

    • capabilities: Iterable<ECapability>

      A collection of capabilities to look for.

    Returns boolean

    true if the device has all the specified capabilities; false if the device doesn't have all of the specified capabilities.

hasCapability

  • Returns a value whether the device contains the specified capability

    Parameters

    Returns boolean

    true if the device has the capability; false if the device doesn't have the capability.

hasCommand

  • hasCommand(command: string): boolean
  • Returns a value whether the device supports the specified command.

    Parameters

    • command: string

      A command string.

    Returns boolean

    true if the device supports the specified command; false if the device doesn't support the specified command.

sendCommand

  • sendCommand(command: string, value?: string | number): Promise<void>
  • Sends a command to the device on Hubitat.

    Parameters

    • command: string

      A command string to send.

    • Optional value: string | number

      An optional value to send.

    Returns Promise<void>

setAttribute

  • setAttribute(attributeName: string, newValue: string | null, forceChangeAnnouncement?: boolean): void
  • Sets a value of an attribute and emits (announces) the device update event if the value has changed.

    Parameters

    • attributeName: string

      A name of the attribute.

    • newValue: string | null

      A new value of the attribute.

    • Default value forceChangeAnnouncement: boolean = false

      If set to true it will announce the device update event regardless whether the value changed or not.

    Returns void

update

  • update(sourceDevice: HubitatDevice, forceAttributeChangeAnnouncement?: boolean): void
  • Updates the device with data from provided device.

    throws

    Throws an error if there's a mismatch between id's of this and provided source device.

    Parameters

    • sourceDevice: HubitatDevice

      A device to copy data from.

    • Default value forceAttributeChangeAnnouncement: boolean = false

      If set to true, it will force the device update event to be emitted. It's false by default.

    Returns void

Generated using TypeDoc