UNPKG

@constructorfleet/ultimate-govee

Version:

Library for interacting with Govee devices written in Typescript.

36 lines 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ControlLockState = exports.ControlLockStateName = void 0; const _ultimate_govee_common_1 = require("../../../common"); const device_state_1 = require("./device.state"); exports.ControlLockStateName = 'controlLock'; class ControlLockState extends device_state_1.DeviceOpState { constructor(device, opType = _ultimate_govee_common_1.OpType.REPORT, ...identifier) { super({ opType, identifier }, device, exports.ControlLockStateName, undefined); this.stateToCommand = (nextState) => { if (!(0, _ultimate_govee_common_1.isTypeOf)(nextState, 'boolean')) { this.logger.warn('state not provided, skipping command.'); return; } return { command: { data: { command: [ (0, _ultimate_govee_common_1.asOpCode)(_ultimate_govee_common_1.OpType.COMMAND, this.identifier, nextState ? 1 : 0), ], }, }, status: { op: { command: [[nextState ? 1 : 0]], }, }, }; }; } parseOpCommand(opCommand) { this.stateValue.next(opCommand[0] === 0x01); } } exports.ControlLockState = ControlLockState; //# sourceMappingURL=control-lock.state.js.map