@constructorfleet/ultimate-govee
Version:
Library for interacting with Govee devices written in Typescript.
40 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeH5106 = exports.H5106 = exports.properties = void 0;
exports.properties = ['temperature', 'hum', 'pm25'];
exports.H5106 = {
brand: 'Govee',
model: 'H5106',
modelName: 'Smart Air Quality Monitor',
type: ['Air Environmental Monitoring Devices'],
};
const decodeH5106 = (advertisement) => {
const packet = parseInt(`0x${Buffer.from(advertisement.manufacturerData).toString('hex').slice(8, 16)}`, 16);
const getTemp = () => {
if (packet & 0x80000000) {
const packetValue = packet & 0x7fffffff;
return Math.floor(packetValue / -10000000) / -10;
}
return Math.floor(packet / 1000000) / 10;
};
const getHum = () => {
return Math.floor(((packet & 0x7fffffff) % 1000000) / 1000) / 10;
};
const getPM25 = () => {
return (packet & 0x7fffffff) % 1000;
};
return {
temperature: {
current: getTemp(),
},
humidity: {
current: getHum(),
},
pm25: {
current: getPM25(),
},
...exports.H5106,
};
};
exports.decodeH5106 = decodeH5106;
//# sourceMappingURL=H5106.decoder.js.map