UNPKG

homebridge-econet-rheem

Version:

Homebridge plugin based on pyeconet for control of Rheem water heaters

74 lines 2.69 kB
import { Equipment } from './equipment.js'; import { TemperatureUnits } from './enums.js'; export class WaterHeater extends Equipment { enabled = false; running = false; temp_units = TemperatureUnits.CELSIUS; lower_limit = 100; upper_limit = 150; set_point = 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor(api, restUpdate) { super(api); this.updateFromREST(restUpdate); } get isEnabled() { return this.enabled; } get isRunning() { return this.running; } get units() { return this.temp_units; } get limits() { return [this.lower_limit, this.upper_limit]; } // Currently not supplied by Econet api get currentTemp() { return this.set_point; } get setPoint() { return this.set_point; } // eslint-disable-next-line @typescript-eslint/no-explicit-any updateFromREST(update) { super.updateFromREST(update); if ('@ENABLED' in update) { this.enabled = update['@ENABLED'].value === 1; } if ('@RUNNING' in update) { this.running = update['@RUNNING'].replace(/\s/g, '').length > 0; } if ('@SETPOINT' in update) { this.temp_units = update['@SETPOINT'].constraints.units === 'deg F' ? TemperatureUnits.FAHRENHEIT : TemperatureUnits.CELSIUS; this.lower_limit = update['@SETPOINT'].constraints.lowerLimit || 100; this.upper_limit = update['@SETPOINT'].constraints.upperLimit || 150; this.set_point = update['@SETPOINT'].value || 0; } this.didUpdate(); } // eslint-disable-next-line @typescript-eslint/no-explicit-any updateFromMQTT(update) { if ('@ENABLED' in update) { this.enabled = update['@ENABLED'] === 1 || update['@ENABLED'].value === 1; this._api.log.debug(`${this.deviceName} enabled = ${this.enabled}`); } if ('@RUNNING' in update) { this.running = update['@RUNNING'].replace(/\s/g, '').length > 0; this._api.log.debug(`${this.deviceName} running = ${this.running}`); } if ('@SETPOINT' in update) { this.set_point = update['@SETPOINT']; this._api.log.debug(`${this.deviceName} set_point = ${this.set_point}`); } this.didUpdate(); } setEnabled(enabled) { this._api.publish({ '@ENABLED': enabled ? 1 : 0 }, this.deviceId, this.serialNumber); } setSetPoint(setPoint) { this._api.publish({ '@SETPOINT': setPoint }, this.deviceId, this.serialNumber); } } //# sourceMappingURL=waterHeater.js.map