homebridge#WithUUID TypeScript Examples

The following examples show how to use homebridge#WithUUID. 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: util.ts    From homebridge-wiz-lan with Apache License 2.0 7 votes vote down vote up
export function turnOffIfNeeded(
  characteristic: WithUUID<{
    new (): Characteristic;
  }>,
  service: Service,
  useSetValue = false
) {
  const ch = service.getCharacteristic(characteristic);
  if (ch?.value !== 0) {
    useSetValue ? ch.setValue(0) : ch.updateValue(0);
  }
}
Example #2
Source File: currentConsumptionCharacteristic.ts    From homebridge-tapo-p100 with Apache License 2.0 6 votes vote down vote up
export default function currentConsumption(
  DefaultCharacteristic: typeof Characteristic,
): WithUUID<new () => Characteristic> {
  return class CurrentConsumptionCharacteristic extends DefaultCharacteristic {
    static readonly UUID = 'E863F10D-079E-48FF-8F27-9C2605A29F52';

    constructor() {
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
      // @ts-ignore: unable to override class constructor parameters as its a type and not a value
      super('Current Consumption', CurrentConsumptionCharacteristic.UUID, {
        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
        // @ts-ignore: custom unit
        unit: 'Watt',
        maxValue: 65535,
        minValue: 0,
        minStep: 1,
      });
    }
  };
}
Example #3
Source File: index.ts    From homebridge-tapo-p100 with Apache License 2.0 6 votes vote down vote up
export default function characteristic(
  Characteristic: typeof CharacteristicClass,
): Record<
    | 'CurrentConsumptionCharacteristic'
    | 'TotalConsumptionCharacteristic',
    WithUUID<new () => CharacteristicClass>
    > {
  const DefaultCharacteristic = DefaultCharacteristicImport(Characteristic);

  return {
    CurrentConsumptionCharacteristic: CurrentConsumptionCharacteristicImport(DefaultCharacteristic),
    TotalConsumptionCharacteristic: TotalConsumptionCharacteristicImport(DefaultCharacteristic),
  };
}
Example #4
Source File: totalConsumptionCharacteristic.ts    From homebridge-tapo-p100 with Apache License 2.0 6 votes vote down vote up
export default function totalConsumption(
  DefaultCharacteristic: typeof Characteristic,
): WithUUID<new () => Characteristic> {
  return class TotalConsumptionCharacteristic extends DefaultCharacteristic {
        static readonly UUID = 'E863F10C-079E-48FF-8F27-9C2605A29F52';

        constructor() {
          // eslint-disable-next-line @typescript-eslint/ban-ts-comment
          // @ts-ignore: unable to override class constructor parameters as its a type and not a value
          super('Total Consumption', TotalConsumptionCharacteristic.UUID, {
            maxValue: 4294967295,
            minValue: 0,
            // eslint-disable-next-line @typescript-eslint/ban-ts-comment
            // @ts-ignore: custom unit
            unit: 'kWh',
            minStep: 0.001,
          });
        }
  };
}
Example #5
Source File: platform.ts    From homebridge-tapo-p100 with Apache License 2.0 5 votes vote down vote up
public customCharacteristics: {
    [key: string]: WithUUID<new () => Characteristic>;
  };