@homebridge-plugins/homebridge-smarthq
Version:
The SmartHQ plugin allows you to interact with SmartHQ Devices in HomeKit and with Siri.
67 lines • 3.11 kB
JavaScript
import { deviceBase } from './device.js';
export class SmartHQWaterSoftener extends deviceBase {
platform;
device;
constructor(platform, accessory, device) {
super(platform, accessory, device);
this.platform = platform;
this.device = device;
this.debugLog(`Water Softener Features: ${JSON.stringify(accessory.context.device.features)}`);
// Water Softener Filter/Salt Status
const filterService = this.accessory.getService('Softener Salt') ?? this.accessory.addService(this.platform.Service.FilterMaintenance, 'Softener Salt', 'SoftenerSalt');
filterService.setCharacteristic(this.platform.Characteristic.Name, 'Softener Salt');
filterService
.getCharacteristic(this.platform.Characteristic.FilterChangeIndication)
.onGet(async () => {
try {
// TODO: Implement salt level ERD
return this.platform.Characteristic.FilterChangeIndication.FILTER_OK;
}
catch (error) {
this.warnLog?.(`Softener Salt Status error: ${error?.message ?? error}`);
return this.platform.Characteristic.FilterChangeIndication.FILTER_OK;
}
});
filterService
.getCharacteristic(this.platform.Characteristic.FilterLifeLevel)
.onGet(async () => {
try {
// TODO: Implement salt level percentage ERD
return 100;
}
catch (error) {
this.warnLog?.(`Softener Salt Level error: ${error?.message ?? error}`);
return 100;
}
});
// Water Valve
const valveService = this.accessory.getService('Water Softener') ?? this.accessory.addService(this.platform.Service.Valve, 'Water Softener', 'WaterSoftener');
valveService.setCharacteristic(this.platform.Characteristic.Name, 'Water Softener');
valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.WATER_FAUCET);
valveService
.getCharacteristic(this.platform.Characteristic.Active)
.onGet(async () => {
try {
// TODO: Implement softener active state ERD
return this.platform.Characteristic.Active.ACTIVE;
}
catch (error) {
this.warnLog?.(`Water Softener Active error: ${error?.message ?? error}`);
return this.platform.Characteristic.Active.INACTIVE;
}
});
valveService
.getCharacteristic(this.platform.Characteristic.InUse)
.onGet(async () => {
try {
// TODO: Implement softener in-use state ERD
return this.platform.Characteristic.InUse.IN_USE;
}
catch (error) {
this.warnLog?.(`Water Softener InUse error: ${error?.message ?? error}`);
return this.platform.Characteristic.InUse.NOT_IN_USE;
}
});
}
}
//# sourceMappingURL=waterSoftener.js.map