homebridge#Nullable TypeScript Examples

The following examples show how to use homebridge#Nullable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TasmotaService.ts    From homebridge-tasmota with Apache License 2.0 6 votes vote down vote up
/**
   * Handle "LWT" Last Will and Testament messages from Tasmota
   * These are sent when the device is no longer available from the MQTT server.
   */

  availabilityUpdate(topic, message) {
    // debug("availabilityUpdate", this, topic, message.toString());
    this.platform.log.info('Marking accessory \'%s\' to %s', this.service.displayName, message);

    if (message.toString() === this.accessory.context.device[this.uniq_id].pl_not_avail) {
      const availability: Nullable<CharacteristicValue> | Error = new Error(this.accessory.displayName + ' ' + message.toString());
      this.characteristic.updateValue(availability);
    } else {
      // debug("availabilityUpdate", this.characteristic);
      this.characteristic.updateValue(this.characteristic.value);
    }
  }