UNPKG

node-mihome

Version:

Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more

48 lines (36 loc) 1.18 kB
const Device = require('../device-miio'); const { withLightEffect } = require('../utils'); module.exports = class extends Device { static model = 'yeelink.light.strip4'; static name = 'Yeelight Willow LED Lightstrip'; static image = 'https://static.home.mi.com/app/image/get/file/developer_155263926836bw2kvq.png'; constructor(opts) { super(opts); this._propertiesToMonitor = ['power', 'bright', 'ct']; } getPower() { const { power } = this.properties; if (power === 'on') return true; if (power === 'off') return false; return undefined; } getBrightness() { const brightness = parseInt(this.properties.bright, 10); if (brightness > 0) return brightness; return undefined; } getColorTemperature() { const colorTemperature = parseInt(this.properties.ct, 10); if (colorTemperature > 0) return colorTemperature; return undefined; } setPower(v) { return this.miioCall('set_power', withLightEffect(v ? 'on' : 'off')); } setBrightness(v) { return this.miioCall('set_bright', withLightEffect(v)); } setColorTemperature(v) { return this.miioCall('set_ct_abx', withLightEffect(v)); } };