homebridge-loxone-proxy
Version:
Homebridge Dynamic Platform Plugin which exposes a Loxone System to Homekit.
58 lines • 2.65 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InfoOnlyAnalog = void 0;
const LoxoneAccessory_1 = require("../../LoxoneAccessory");
const HumiditySensor_1 = require("../../homekit/services/HumiditySensor");
const LightSensor_1 = require("../../homekit/services/LightSensor");
const TemperatureSensor_1 = require("../../homekit/services/TemperatureSensor");
class InfoOnlyAnalog extends LoxoneAccessory_1.LoxoneAccessory {
isSupported() {
var _a;
const { config } = this.platform;
const aliases = config.InfoOnlyAnalogAlias;
const serviceTypeMap = new Map([
['Temperature', TemperatureSensor_1.TemperatureSensor],
['Brightness', LightSensor_1.LightSensor],
['Humidity', HumiditySensor_1.HumiditySensor],
]);
const formatTypeMap = new Map([
['%.1f°', TemperatureSensor_1.TemperatureSensor],
['%.0fLx', LightSensor_1.LightSensor],
['%.0f%%', HumiditySensor_1.HumiditySensor],
]);
const format = (_a = this.device.details) === null || _a === void 0 ? void 0 : _a.format;
if (format && formatTypeMap.has(format)) {
const detectedService = formatTypeMap.get(format);
const serviceName = detectedService.name;
this.platform.log.info(`[InfoOnlyAnalogItem] Format for ${serviceName} detected for device: ${this.device.name}`);
this.assignServiceType(detectedService);
return true;
}
for (const [key, alias] of Object.entries(aliases)) {
if (this.matchAlias(this.device.name, alias)) {
const trimmedKey = key.trim();
const serviceType = serviceTypeMap.get(trimmedKey);
if (serviceType) {
this.platform.log.info(`[InfoOnlyAnalogItem] Matched alias: '${alias}' to service: '${trimmedKey}' for device: ${this.device.name}`);
this.assignServiceType(serviceType);
return true;
}
}
}
return false;
}
assignServiceType(serviceType) {
this.ServiceType = serviceType;
this.device.name = `${this.device.room} (${this.device.name})`;
}
configureServices() {
this.ItemStates = {
[this.device.states.value]: { service: 'PrimaryService', state: 'value' },
};
if (this.ServiceType) {
this.Service.PrimaryService = new this.ServiceType(this.platform, this.Accessory);
}
}
}
exports.InfoOnlyAnalog = InfoOnlyAnalog;
//# sourceMappingURL=InfoOnlyAnalog.js.map