UNPKG

@constructorfleet/ultimate-govee

Version:

Library for interacting with Govee devices written in Typescript.

24 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LightEffectState = exports.LightEffectStateName = void 0; const _ultimate_govee_common_1 = require("../../../common"); const rxjs_1 = require("rxjs"); const device_state_1 = require("./device.state"); exports.LightEffectStateName = 'lightEffect'; class LightEffectState extends device_state_1.DeviceOpState { constructor(device, opType = _ultimate_govee_common_1.OpType.REPORT, identifier = [0x05]) { super({ opType, identifier }, device, exports.LightEffectStateName, {}); this.effects = new _ultimate_govee_common_1.DeltaMap(); this.activeEffectCode = new rxjs_1.BehaviorSubject(undefined); this.activeEffectCode.subscribe((effectCode) => this.stateValue.next(this.effects.get(effectCode ?? -1) ?? {})); this.effects.delta$.subscribe(() => { this.stateValue.next(this.stateValue.getValue()); }); } parseOpCommand(opCommand) { const effectCode = (0, _ultimate_govee_common_1.total)(opCommand.slice(0, 2)); this.activeEffectCode.next(effectCode); } } exports.LightEffectState = LightEffectState; //# sourceMappingURL=light-effect.state.js.map