UNPKG

@constructorfleet/ultimate-govee

Version:

Library for interacting with Govee devices written in Typescript.

45 lines 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TargetHumidityState = exports.TargetHumidityStateName = void 0; const states_1 = require("../../../states"); const humidifier_modes_1 = require("./humidifier.modes"); exports.TargetHumidityStateName = 'targetHumidity'; class TargetHumidityState extends states_1.DeviceState { constructor(device, activeState) { super(device, exports.TargetHumidityStateName, undefined); this.activeState = activeState; this.stateToCommand = () => { return undefined; }; this.activeState?.subscribe((event) => { if (this.subscription !== undefined) { this.subscription.unsubscribe(); } if (event?.name === 'modeAuto') { this.subscription = event?.subscribe((event) => { this.stateValue.next(event.value.targetHumidity); }); } else { this.stateValue.next(undefined); } }); } setState(nextState) { if (nextState === undefined) { this.logger.warn('Target humidity not specified, ignoring command'); return []; } if (this.activeState.value?.name !== humidifier_modes_1.AutoModeStateName) { this.logger.log('Target humidtiy can only be set in Auto, changing to to Auto'); return (this.activeState.modes .find((m) => m.name === humidifier_modes_1.AutoModeStateName) ?.setState(nextState) ?? []); } else { return this.activeState.value.setState(nextState); } } } exports.TargetHumidityState = TargetHumidityState; //# sourceMappingURL=humidifier.target-humidity.js.map