homebridge-loxone-proxy
Version:
Homebridge Dynamic Platform Plugin which exposes a Loxone System to Homekit.
41 lines • 1.89 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Radio = void 0;
const LoxoneAccessory_1 = require("../../LoxoneAccessory");
const Outlet_1 = require("../../homekit/services/Outlet");
class Radio extends LoxoneAccessory_1.LoxoneAccessory {
configureServices() {
this.ItemStates = {
[this.device.states.activeOutput]: { 'service': 'PrimaryService', 'state': 'activeOutput' },
};
this.registerRadioSwitches();
}
registerRadioSwitches() {
this.device.details.outputs[0] = this.device.details.allOff;
for (const radioSwitchKey in this.device.details.outputs) {
const radioSwitch = this.device.details.outputs[radioSwitchKey];
const radioItem = { ...this.device };
radioItem.name = radioSwitch;
radioItem.type = 'Switch';
radioItem.cat = radioSwitchKey;
radioItem.details = {};
this.Service[radioItem.name] = new Outlet_1.Outlet(this.platform, this.Accessory, radioItem, this.handleLoxoneCommand.bind(this));
}
}
callBackHandler(message) {
const currentValue = message.value;
for (const serviceName in this.Service) {
const service = this.Service[serviceName];
message.value = currentValue === parseInt(service.device.cat) ? 1 : 0;
const updateService = new Function('message', `return this.Service["${serviceName}"].updateService(message);`);
updateService.call(this, message);
}
}
handleLoxoneCommand(value) {
const command = parseInt(value) === 0 ? 'reset' : value;
this.platform.log.debug(`[${this.device.name}] Send command to Loxone: ${command}`);
this.platform.LoxoneHandler.sendCommand(this.device.uuidAction, command);
}
}
exports.Radio = Radio;
//# sourceMappingURL=Radio.js.map