UNPKG

@homenet/plugin-milight

Version:
39 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const events_1 = require("events"); class MilightLight extends events_1.EventEmitter { constructor(instanceId, groupId, bridge, logger) { super(); this.groupId = groupId; this.bridge = bridge; this.logger = logger; this.id = instanceId; this.state = 'unknown'; } get() { return this.state; } set(value) { let state; if (value === false) state = 'off'; else if (value === true) state = 'full'; else state = value; switch (state) { case 'full': this.bridge.turnOn(this.groupId); break; case 'off': this.bridge.turnOff(this.groupId); break; default: return; } this.state = state; this.emit('update', state); } } exports.MilightLight = MilightLight; //# sourceMappingURL=light.js.map