UNPKG

homebridge-z2m

Version:

Expose your Zigbee devices to HomeKit with ease, by integrating Zigbee2MQTT with Homebridge.

38 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LightSensorHandler = void 0; const hap_1 = require("../../hap"); const helpers_1 = require("../../helpers"); const z2mModels_1 = require("../../z2mModels"); const monitor_1 = require("../monitor"); const basic_1 = require("./basic"); class LightSensorHandler extends basic_1.BasicSensorHandler { static exposesName = 'illuminance_lux'; // Since Zigbee2MQTT v2 illuminance_lux has been renamed to illuminance, // by using illuminance as fallback both v1 and v2 are supported. static fallbackExposesNames = ['illuminance']; static exposesType = z2mModels_1.ExposesKnownTypes.NUMERIC; mainCharacteristics = []; constructor(expose, allExposes, accessory) { super(accessory, expose, allExposes, LightSensorHandler.generateIdentifier, (n, t) => new hap_1.hap.Service.LightSensor(n, t)); accessory.log.debug(`Configuring LightSensor for ${this.serviceName}`); const characteristic = (0, helpers_1.getOrAddCharacteristic)(this.service, hap_1.hap.Characteristic.CurrentAmbientLightLevel); if (!(0, helpers_1.copyExposesRangeToCharacteristic)(expose, characteristic)) { // Cannot take over range from exposes entry -> Set default props characteristic.setProps({ minValue: 0, }); } this.mainCharacteristics.push(characteristic); this.monitors.push(new monitor_1.PassthroughCharacteristicMonitor(expose.property, this.service, hap_1.hap.Characteristic.CurrentAmbientLightLevel)); } static generateIdentifier(endpoint) { let identifier = hap_1.hap.Service.LightSensor.UUID; if (endpoint !== undefined) { identifier += '_' + endpoint.trim(); } return identifier; } } exports.LightSensorHandler = LightSensorHandler; //# sourceMappingURL=light.js.map