homebridge-rinnai-touch-platform
Version:
Homebridge Plugin to control heating/cooling via a Rinnai Touch WiFi Module
67 lines • 2.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccessoryBase = void 0;
const crypto = require("crypto");
class AccessoryBase {
constructor(platform, platformAccessory) {
this.platform = platform;
this.platformAccessory = platformAccessory;
this.modeNames = {
A: '',
H: 'Heat',
C: 'Cool',
E: 'Cool',
F: 'Fan',
};
this.setAccessoryInformation();
}
setAccessoryInformation() {
this.platform.log.debug('AccessoryBase', 'setAccessoryInformation');
const service = this.platformAccessory.getService(this.platform.Service.AccessoryInformation);
service
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Rinnai')
.setCharacteristic(this.platform.Characteristic.Model, 'N-BW2')
.setCharacteristic(this.platform.Characteristic.SerialNumber, crypto.createHash('sha1').update(this.platformAccessory.UUID).digest('hex'));
}
setEventHandlers() {
this.platform.log.debug('AccessoryBase', 'setEventHandlers');
this.platform.service.session.on('status', () => {
this.updateValues();
});
this.platformAccessory.on('identify', () => {
this.platform.log.info(`Identified: ${this.platformAccessory.displayName}`);
});
}
getCharacteristicValue(getValue, characteristic) {
this.platform.log.debug('AccessoryBase', 'getCharacteristicValue', 'getValue', characteristic);
if (this.platform.settings.showHomebridgeEvents) {
this.platform.log.info(`${this.platformAccessory.displayName}: Getting characteristic '${characteristic}'`);
}
try {
return getValue();
}
catch (error) {
if (error instanceof Error) {
this.platform.log.error(error.message);
}
throw error;
}
}
async setCharacteristicValue(setValue, characteristic, value) {
this.platform.log.debug('AccessoryBase', 'setCharacteristicValue', 'setValue', characteristic, value);
if (this.platform.settings.showHomebridgeEvents) {
this.platform.log.info(`${this.platformAccessory.displayName}: Setting characteristic '${characteristic}' to '${value}'`);
}
try {
await setValue(value);
}
catch (error) {
if (error instanceof Error) {
this.platform.log.error(error.message);
}
throw error;
}
}
}
exports.AccessoryBase = AccessoryBase;
//# sourceMappingURL=AccessoryBase.js.map