Skip to content

Commit 8a70e68

Browse files
EyenseoKoenkk
andauthored
fix: Fix CO2 value interpretation (#8644)
Co-authored-by: Koen Kanters <[email protected]>
1 parent 5c562da commit 8a70e68

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/converters/fromZigbee.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ const converters1 = {
503503
cluster: 'msCO2',
504504
type: ['attributeReport', 'readResponse'],
505505
convert: (model, msg, publish, options, meta) => {
506-
return {co2: Math.floor(msg.data.measuredValue * 1000000)};
506+
return {co2: Math.floor(1 / msg.data.measuredValue)};
507507
},
508508
} satisfies Fz.Converter,
509509
occupancy: {

src/lib/modernExtend.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -941,15 +941,18 @@ export function occupancy(args?: OccupancyArgs): ModernExtend {
941941
}
942942

943943
export function co2(args?: Partial<NumericArgs>) {
944+
const fractionOf1: ScaleFunction = (value: number, type: 'from' | 'to') => {
945+
return 1 / value;
946+
};
944947
return numeric({
945948
name: 'co2',
946949
cluster: 'msCO2',
947950
label: 'CO2',
948951
attribute: 'measuredValue',
949-
reporting: {min: '10_SECONDS', max: '1_HOUR', change: 0.00005}, // 50 ppm change
952+
reporting: {min: '10_SECONDS', max: '1_HOUR', change: fractionOf1(50 /*ppm*/, 'to')},
950953
description: 'Measured value',
951954
unit: 'ppm',
952-
scale: 0.000001,
955+
scale: fractionOf1,
953956
access: 'STATE_GET',
954957
...args,
955958
});

0 commit comments

Comments
 (0)