UNPKG

homebridge-rinnai-touch-platform

Version:

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

62 lines 2.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Pump = void 0; const AccessoryBase_1 = require("./AccessoryBase"); const RinnaiService_1 = require("../rinnai/RinnaiService"); class Pump extends AccessoryBase_1.AccessoryBase { constructor(platform, platformAccessory) { var _a; super(platform, platformAccessory); this.service = (_a = this.platformAccessory.getService(this.platform.Service.Valve)) !== null && _a !== void 0 ? _a : this.platformAccessory.addService(this.platform.Service.Valve, platformAccessory.displayName); this.setEventHandlers(); } setEventHandlers() { this.platform.log.debug(this.constructor.name, 'setEventHandlers'); super.setEventHandlers(); this.service .getCharacteristic(this.platform.Characteristic.Active) .onGet(this.getCharacteristicValue.bind(this, this.getPumpActive.bind(this), 'Active')) .onSet(this.setCharacteristicValue.bind(this, this.setPumpActive.bind(this), 'Active')); this.service .getCharacteristic(this.platform.Characteristic.InUse) .onGet(this.getCharacteristicValue.bind(this, this.getPumpInUse.bind(this), 'InUse')); } getPumpActive() { this.platform.log.debug(this.constructor.name, 'getPumpActive'); const state = this.platform.service.getPumpState(); return state ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE; } getPumpInUse() { this.platform.log.debug(this.constructor.name, 'getPumpInUse'); const state = this.platform.service.getPumpState(); return state ? this.platform.Characteristic.InUse.IN_USE : this.platform.Characteristic.InUse.NOT_IN_USE; } async setPumpActive(value) { this.platform.log.debug(this.constructor.name, 'setPumpActive', value); const state = value === this.platform.Characteristic.Active.ACTIVE; if (value) { await this.platform.service.setOperatingMode(RinnaiService_1.OperatingModes.EVAPORATIVE_COOLING); await this.platform.service.setPowerState(true); await this.platform.service.setControlMode(RinnaiService_1.ControlModes.MANUAL); } await this.platform.service.setPumpState(state); } updateValues() { this.platform.log.debug(this.constructor.name, 'updateValues'); this.service .getCharacteristic(this.platform.Characteristic.Active) .updateValue(this.getPumpActive()); this.service .getCharacteristic(this.platform.Characteristic.InUse) .updateValue(this.getPumpInUse()); this.service .getCharacteristic(this.platform.Characteristic.ValveType) .updateValue(this.platform.Characteristic.ValveType.GENERIC_VALVE); } } exports.Pump = Pump; //# sourceMappingURL=Pump.js.map