UNPKG

homebridge-eufy-security

Version:
53 lines 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EntrySensorAccessory = void 0; const Device_1 = require("./Device"); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const eufy_security_client_1 = require("eufy-security-client"); const utils_1 = require("../utils/utils"); /** * EntrySensorAccessory Class * * This class represents an entry sensor accessory within a home automation system. It is designed * to integrate entry sensors into the system, register appropriate characteristics, and provide * necessary functionality for monitoring the open or closed state of doors or windows. * * @class EntrySensorAccessory * @extends DeviceAccessory */ class EntrySensorAccessory extends Device_1.DeviceAccessory { /** * Constructor for EntrySensorAccessory. * * @param {EufySecurityPlatform} platform - The platform instance managing accessories. * @param {PlatformAccessory} accessory - The platform-specific accessory. * @param {EntrySensor} device - The entry sensor device being represented. */ constructor(platform, accessory, device) { // Call the constructor of the parent class DeviceAccessory. super(platform, accessory, device); // Log a debug message indicating the construction of the Entry Sensor. this.log.debug(`Constructed Entry Sensor`); // Check if the device has the 'sensorOpen' property. if (this.device.hasProperty('sensorOpen')) { // Register the Contact Sensor characteristic. this.registerCharacteristic({ serviceType: utils_1.SERV.ContactSensor, characteristicType: utils_1.CHAR.ContactSensorState, getValue: () => this.device.getPropertyValue(eufy_security_client_1.PropertyName.DeviceSensorOpen), onSimpleValue: 'open', }); // Initialize the sensor service. this.initSensorService(); } else { // Log an error if the 'sensorOpen' property is not available for this device. this.log.error(`has no sensorOpen`); } // Remove any unused services. this.pruneUnusedServices(); } } exports.EntrySensorAccessory = EntrySensorAccessory; //# sourceMappingURL=EntrySensorAccessory.js.map