UNPKG

@constructorfleet/ultimate-govee

Version:

Library for interacting with Govee devices written in Typescript.

90 lines 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PM25State = exports.PM25StateName = exports.TemperatureState = exports.HumidityState = void 0; const humidity_state_1 = require("../../../states/humidity.state"); const temperature_state_1 = require("../../../states/temperature.state"); const states_types_1 = require("../../../states/states.types"); const device_state_1 = require("../../../states/device.state"); class HumidityState extends humidity_state_1.HumidityState { constructor(device) { super(device, null, states_types_1.ParseOption.multiOp); } parseMultiOpCommand(opCommands) { const opCommand = opCommands[0]; const raw = ((opCommand[9] << 8) | opCommand[10]) / 100; const rawCal = (opCommand[11] << 8) | opCommand[12]; const calibration = ((rawCal & 0x7fff) - (rawCal & 0x8000)) / 100; const current = raw + calibration; this.stateValue.next({ ...this.stateValue.getValue(), raw, calibration, current, unit: '%', }); } } exports.HumidityState = HumidityState; class TemperatureState extends temperature_state_1.TemperatureState { constructor(device) { super(device, null, states_types_1.ParseOption.multiOp); this.parseOption = states_types_1.ParseOption.multiOp.or(states_types_1.ParseOption.state); } parseMultiOpCommand(opCommands) { const opCommand = opCommands[0]; const raw = ((opCommand[0] << 8) | opCommand[1]) / 100; const rawCal = (opCommand[2] << 8) | opCommand[3]; const calibration = ((rawCal & 0x7fff) - (rawCal & 0x8000)) / 100; const current = raw + calibration; // const unit = opCommands[1][8] === 1 ? 'F' : 'C'; this.stateValue.next({ ...this.stateValue.getValue(), raw, calibration, current, unit: 'C', }); } } exports.TemperatureState = TemperatureState; exports.PM25StateName = 'pm25'; class PM25State extends device_state_1.DeviceOpState { constructor(device) { super({ opType: null, identifier: null }, device, exports.PM25StateName, {}, states_types_1.ParseOption.multiOp.or(states_types_1.ParseOption.state)); } parseMultiOpCommand(opCommands) { const opCommand = opCommands[0]; this.stateValue.next({ range: { min: 0, max: 1000, }, current: (opCommand[18] << 8) | opCommand[19], unit: '\u00B5g/m\u00B3', }); } parseState(data) { if (data?.pm25 !== undefined) { this.stateValue.next({ range: { min: 0, max: 1000, }, current: data.pm25.current, }); } } } exports.PM25State = PM25State; // Warning [0n 4] High [5 6] / 100 Low [7 8] / 100 // Unit line 2 [8] 0 = F, 1 = C // Display line 2 [5] 0 = PM2.5 1 = Time // Time 24H [7] 0 = 12H, 1 = 24H // Daytime Display [7] 0 = off 1 =on // Start = hour [9] min [10] // Brighness = [11] 1 - 7 // Nightime display [15] 0 = off 1 = on // // Brightness = [19] 1 - 7 // Warning [0n 13] low [16 17] high[14 15] //# sourceMappingURL=air-quality.states.js.map