UNPKG

homebridge-rinnai-touch-platform

Version:

Homebridge Plugin to control heating/cooling via a Rinnai Touch WiFi Module

79 lines 3.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ManualSwitch = void 0; const RinnaiService_1 = require("../rinnai/RinnaiService"); const AccessoryBase_1 = require("./AccessoryBase"); const RinnaiService_2 = require("../rinnai/RinnaiService"); class ManualSwitch 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.getManualSwitchOn.bind(this), 'On')) .onSet(this.setCharacteristicValue.bind(this, this.setManualSwitchOn.bind(this), 'On')); } getManualSwitchOn() { this.platform.log.debug(this.constructor.name, 'getManualSwitchOn'); let state = RinnaiService_1.ControlModes.AUTO; switch (this.platformAccessory.context.mode) { case 'A': state = this.platform.service.getControlMode(this.platformAccessory.context.zone); break; case 'H': if (this.platform.service.getOperatingMode() === RinnaiService_2.OperatingModes.HEATING) { state = this.platform.service.getControlMode(this.platformAccessory.context.zone); } break; case 'C': if (this.platform.service.getOperatingMode() === RinnaiService_2.OperatingModes.COOLING) { state = this.platform.service.getControlMode(this.platformAccessory.context.zone); } break; case 'E': if (this.platform.service.getOperatingMode() === RinnaiService_2.OperatingModes.EVAPORATIVE_COOLING) { state = this.platform.service.getControlMode(this.platformAccessory.context.zone); } break; } return state === RinnaiService_1.ControlModes.MANUAL; } async setManualSwitchOn(value) { this.platform.log.debug(this.constructor.name, 'setManualSwitchOn', value); if (value) { switch (this.platformAccessory.context.mode) { case 'H': await this.platform.service.setOperatingMode(RinnaiService_2.OperatingModes.HEATING); break; case 'C': await this.platform.service.setOperatingMode(RinnaiService_2.OperatingModes.COOLING); break; case 'E': await this.platform.service.setOperatingMode(RinnaiService_2.OperatingModes.EVAPORATIVE_COOLING); break; } if (!this.platform.service.getPowerState()) { await this.platform.service.setFanState(false); await this.platform.service.setPowerState(true); } } const state = value ? RinnaiService_1.ControlModes.MANUAL : RinnaiService_1.ControlModes.AUTO; await this.platform.service.setControlMode(state, this.platformAccessory.context.zone); } updateValues() { this.platform.log.debug(this.constructor.name, 'updateValues'); this.service .getCharacteristic(this.platform.Characteristic.On) .updateValue(this.getManualSwitchOn()); } } exports.ManualSwitch = ManualSwitch; //# sourceMappingURL=ManualSwitch.js.map