UNPKG

redmatic-homekit

Version:

HAP-Nodejs based Node-RED nodes to create HomeKit Accessories

22 lines (18 loc) 898 B
const Accessory = require('./lib/accessory'); module.exports = class HmipSmi extends Accessory { init(config) { this.addService('MotionSensor', config.name) .get('MotionDetected', config.deviceAddress + ':1.MOTION') .get('StatusTampered', config.deviceAddress + ':0.SABOTAGE'); this.addService('BatteryService', config.name) .get('StatusLowBattery', config.deviceAddress + ':0.LOW_BAT', (value, c) => { return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL; }) .get('BatteryLevel', config.deviceAddress + ':0.OPERATING_VOLTAGE', this.percent) .update('ChargingState', 2); if (this.option('LightSensor')) { this.addService('LightSensor', config.name) .get('CurrentAmbientLightLevel', config.deviceAddress + ':1.ILLUMINATION'); } } };