UNPKG

homebridge-eufy-security

Version:
53 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MotionSensorAccessory = 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"); /** * MotionSensorAccessory Class * * This class represents a motion sensor accessory within a home automation system. It is designed * to integrate motion sensors into the system, register appropriate characteristics, and provide * necessary functionality for motion detection. * * @class MotionSensorAccessory * @extends DeviceAccessory */ class MotionSensorAccessory extends Device_1.DeviceAccessory { /** * Constructor for MotionSensorAccessory. * * @param {EufySecurityPlatform} platform - The platform instance managing accessories. * @param {PlatformAccessory} accessory - The platform-specific accessory. * @param {MotionSensor} device - The motion 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 Motion Sensor. this.log.debug(`Constructed Motion Sensor`); // Check if the device has the 'motionDetected' property. if (this.device.hasProperty('motionDetected')) { // Register the Motion Detected characteristic. this.registerCharacteristic({ serviceType: utils_1.SERV.MotionSensor, characteristicType: utils_1.CHAR.MotionDetected, getValue: () => this.device.getPropertyValue(eufy_security_client_1.PropertyName.DeviceMotionDetected), onSimpleValue: 'motion detected', }); // Initialize the sensor service. this.initSensorService(); } else { // Log an error if the 'motionDetected' property is not available for this device. this.log.error(`has no motionDetected`); } // Remove any unused services. this.pruneUnusedServices(); } } exports.MotionSensorAccessory = MotionSensorAccessory; //# sourceMappingURL=MotionSensorAccessory.js.map