UNPKG

redmatic-homekit

Version:

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

23 lines (18 loc) 920 B
const Accessory = require('./lib/accessory'); module.exports = class HmWs550 extends Accessory { init(config) { this.addService('TemperatureSensor', config.name) .setProps('CurrentTemperature', {minValue: -40, maxValue: 80}) .get('CurrentTemperature', config.deviceAddress + ':10.TEMPERATURE') .get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => { return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL; }); if (this.option('HumiditySensor')) { this.addService('HumiditySensor', config.name) .get('CurrentRelativeHumidity', config.deviceAddress + ':10.HUMIDITY') .get('StatusLowBattery', config.deviceAddress + ':0.LOWBAT', (value, c) => { return value ? c.BATTERY_LEVEL_LOW : c.BATTERY_LEVEL_NORMAL; }); } } };