UNPKG

redmatic-homekit

Version:

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

27 lines (21 loc) 954 B
const Accessory = require('./lib/accessory'); module.exports = class HmSw extends Accessory { init(config, node) { const {ccu} = node; const channels = config.description.CHILDREN; for (let i = 1; i < channels.length; i++) { const ch = config.description.ADDRESS + ':' + i; if (config.options[ch] && config.options[ch].disabled) { continue; } const name = ccu.channelNames[channels[i]]; const dp = config.iface + '.' + channels[i] + '.TEMPERATURE'; this.addService('TemperatureSensor', name) .setProps('CurrentTemperature', {minValue: -150, maxValue: 150}) .get('CurrentTemperature', dp) .get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => { return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL; }); } } };