UNPKG

homebridge-econet-rheem

Version:

Homebridge plugin based on pyeconet for control of Rheem water heaters

59 lines 1.77 kB
import { TemperatureUnits } from './constants.js'; import strings from '../lang/en.js'; export class Equipment { api; device_id; serial_number; device_name; alert_count = 0; temp_units = TemperatureUnits.CELSIUS; running = false; _onUpdateCallback = null; constructor(api, data) { this.api = api; this.device_id = data.device_name; this.serial_number = data.serial_number; this.device_name = data['@NAME']?.value ?? strings.brand; this.alert_count = data['@ALERTCOUNT'] ?? 0; this.temp_units = data['@SETPOINT']?.constraints?.units?.includes('F') ? TemperatureUnits.FAHRENHEIT : TemperatureUnits.CELSIUS; } get deviceId() { return this.device_id || strings.undefined; } get serialNumber() { return this.serial_number || strings.undefined; } get deviceName() { return this.device_name || strings.undefined; } get hasAlert() { return this.alert_count > 0; } get units() { return this.temp_units; } get isRunning() { return this.running; } get log() { return this.api.log; } setOnUpdateCallback(callback) { this._onUpdateCallback = callback; } didUpdate() { if (this._onUpdateCallback) { this._onUpdateCallback(this.serialNumber); } } updateFromMQTT(update) { if (update['@ALERTCOUNT'] !== undefined) { this.alert_count = update['@ALERTCOUNT']; this.log.ifVerbose(strings.alertCount, this.deviceName, this.alert_count); } } publish(payload, deviceId, serialNumber) { this.api.publish(payload, deviceId, serialNumber); } } //# sourceMappingURL=equipment.js.map