homebridge-rinnai-touch-platform
Version:
Homebridge Plugin to control heating/cooling via a Rinnai Touch WiFi Module
74 lines • 3.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdvanceSwitch = void 0;
const RinnaiService_1 = require("../rinnai/RinnaiService");
const AccessoryBase_1 = require("./AccessoryBase");
class AdvanceSwitch extends AccessoryBase_1.AccessoryBase {
constructor(platform, platformAccessory) {
var _a;
super(platform, platformAccessory);
this.service = (_a = this.platformAccessory.getService(this.platform.Service.Switch)) !== null && _a !== void 0 ? _a : this.platformAccessory.addService(this.platform.Service.Switch, platformAccessory.displayName);
this.setEventHandlers();
}
setEventHandlers() {
this.platform.log.debug(this.constructor.name, 'setEventHandlers');
super.setEventHandlers();
this.service
.getCharacteristic(this.platform.Characteristic.On)
.onGet(this.getCharacteristicValue.bind(this, this.getAdvanceSwitchOn.bind(this), 'On'))
.onSet(this.setCharacteristicValue.bind(this, this.setAdvanceSwitchOn.bind(this), 'On'));
}
getAdvanceSwitchOn() {
this.platform.log.debug(this.constructor.name, 'getAdvanceSwitchOn');
let state = RinnaiService_1.ScheduleOverrideModes.NONE;
switch (this.platformAccessory.context.mode) {
case 'A':
state = this.platform.service.getScheduleOverride(this.platformAccessory.context.zone);
break;
case 'H':
if (this.platform.service.getOperatingMode() === RinnaiService_1.OperatingModes.HEATING) {
state = this.platform.service.getScheduleOverride(this.platformAccessory.context.zone);
}
break;
case 'C':
if (this.platform.service.getOperatingMode() === RinnaiService_1.OperatingModes.COOLING) {
state = this.platform.service.getScheduleOverride(this.platformAccessory.context.zone);
}
break;
}
return state === RinnaiService_1.ScheduleOverrideModes.ADVANCE;
}
async setAdvanceSwitchOn(value) {
this.platform.log.debug(this.constructor.name, 'setAdvanceSwitchOn', value);
if (this.platform.service.getOperatingMode() === RinnaiService_1.OperatingModes.EVAPORATIVE_COOLING) {
return;
}
if (value) {
switch (this.platformAccessory.context.mode) {
case 'H':
await this.platform.service.setOperatingMode(RinnaiService_1.OperatingModes.HEATING);
break;
case 'C':
await this.platform.service.setOperatingMode(RinnaiService_1.OperatingModes.COOLING);
break;
}
if (!this.platform.service.getPowerState()) {
await this.platform.service.setFanState(false);
await this.platform.service.setPowerState(true);
}
}
const state = value
? RinnaiService_1.ScheduleOverrideModes.ADVANCE
: RinnaiService_1.ScheduleOverrideModes.NONE;
await this.platform.service.setControlMode(RinnaiService_1.ControlModes.AUTO, this.platformAccessory.context.zone);
await this.platform.service.setScheduleOverride(state, this.platformAccessory.context.zone);
}
updateValues() {
this.platform.log.debug(this.constructor.name, 'updateValues');
this.service
.getCharacteristic(this.platform.Characteristic.On)
.updateValue(this.getAdvanceSwitchOn());
}
}
exports.AdvanceSwitch = AdvanceSwitch;
//# sourceMappingURL=AdvanceSwitch.js.map