UNPKG

homebridge-econet-rheem

Version:

Homebridge plugin for control of Rheem and Ruud thermostats and water heaters

70 lines 2.69 kB
import { strings } from '../../i18n/i18n.js'; import { CustomCharacteristicKey } from '../../model/enums.js'; let CustomCharacteristicKeys; export function isCustomCharacteristic(key) { if (CustomCharacteristicKeys === undefined) { CustomCharacteristicKeys = new Set(Object.values(CustomCharacteristicKey)); } return CustomCharacteristicKeys.has(key); } const CustomCharacteristics = {}; export function CustomCharacteristic(key, Characteristic) { if (CustomCharacteristics[key] === undefined) { const char = new Custom(key); CustomCharacteristics[key] = class extends Characteristic { constructor() { super(char.name, char.uuid, { format: "uint32" /* Formats.UINT32 */, perms: ["pr" /* Perms.PAIRED_READ */, "ev" /* Perms.NOTIFY */], unit: char.units, }); this.value = this.getDefaultValue(); } }; CustomCharacteristics[key].UUID = char.uuid; } return CustomCharacteristics[key]; } class Custom { key; constructor(key) { this.key = key; } get name() { switch (this.key) { case CustomCharacteristicKey.AlarmDescription: return ''; case CustomCharacteristicKey.AmbientTemperature: return strings.characteristic.ambientTemperature; case CustomCharacteristicKey.HotWaterAvailable: return strings.characteristic.hotWaterAvailable; case CustomCharacteristicKey.RecoveryRate: return strings.characteristic.recoveryRate; } } get uuid() { switch (this.key) { case CustomCharacteristicKey.AlarmDescription: return ''; case CustomCharacteristicKey.AmbientTemperature: return 'e9638ce8-19ad-468f-a4e8-a65042137a5f'; case CustomCharacteristicKey.HotWaterAvailable: return 'f127b4a0-6d4b-48fd-8533-f5f4001152f2'; case CustomCharacteristicKey.RecoveryRate: return '794fae1a-8f69-4c50-8b40-b135216f79dd'; } } get units() { switch (this.key) { case CustomCharacteristicKey.AlarmDescription: return ''; case CustomCharacteristicKey.AmbientTemperature: return "celsius" /* Units.CELSIUS */; case CustomCharacteristicKey.HotWaterAvailable: return '%'; case CustomCharacteristicKey.RecoveryRate: return strings.characteristic.recoveryRateUnits; } } } //# sourceMappingURL=custom.js.map