homebridge-rinnai-touch-platform
Version:
Homebridge Plugin to control heating/cooling via a Rinnai Touch WiFi Module
45 lines • 1.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TemperatureService = void 0;
const events = require("events");
class TemperatureService extends events.EventEmitter {
constructor(platform) {
super();
this.platform = platform;
this.temperatures = {};
this.override = {};
this.setMaxListeners(15);
for (const zone of this.platform.service.AllZones) {
this.temperatures[zone] = undefined;
this.override[zone] = false;
}
this.platform.service.session.on('status', () => {
let temperatureChanged = false;
for (const zone of this.platform.service.AllZones) {
const temperature = this.platform.service.getMeasuredTemperature(zone);
if (temperature !== undefined && temperature !== this.temperatures[zone] && !this.override[zone]) {
this.temperatures[zone] = temperature;
temperatureChanged = true;
}
}
if (temperatureChanged) {
this.emit('temperature_change', this.getTemperatures());
}
});
}
getTemperature(zone = 'U') {
return this.temperatures[zone];
}
getTemperatures() {
return this.temperatures;
}
setTemperature(zone, temperature) {
if (temperature !== this.temperatures[zone]) {
this.temperatures[zone] = temperature;
this.override[zone] = true;
this.emit('temperature_change', this.getTemperatures());
}
}
}
exports.TemperatureService = TemperatureService;
//# sourceMappingURL=TemperatureService.js.map