UNPKG

redmatic-homekit

Version:

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

32 lines (25 loc) 977 B
const Accessory = require('./lib/accessory'); module.exports = class HbUniSenAct extends Accessory { init(config, node) { const {ccu} = node; const channels = config.description.CHILDREN; for (let i = 1; i <= 4; i++) { if (!this.option(i)) { continue; } const name = ccu.channelNames[channels[i]]; const dp = config.iface + '.' + channels[i] + '.STATE'; this.addService('Switch', name) .get('On', dp) .set('On', dp); } this.addService('BatteryService') .get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => { return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL; }) .get('BatteryLevel', config.deviceAddress + ':0.LOWBAT', value => { return value ? 0 : 100; }) .update('ChargingState', 2); } };