UNPKG

redmatic-homekit

Version:

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

29 lines (25 loc) 954 B
const Accessory = require('./lib/accessory'); module.exports = class HmwLcBl1 extends Accessory { init(config) { this.addService('WindowCovering', config.name) .get('CurrentPosition', config.deviceAddress + ':3.LEVEL', value => { return value * 100; }) .get('TargetPosition', config.deviceAddress + ':3.LEVEL', value => { return value * 100; }) .set('TargetPosition', config.deviceAddress + ':3.LEVEL', value => { return value / 100; }) .get('PositionState', config.deviceAddress + ':3.DIRECTION', (value, c) => { switch (value) { case 1: return c.INCREASING; case 2: return c.DECREASING; default: return c.STOPPED; } }); } };