Skip to content

Commit

Permalink
Fix CO2 value interpretation
Browse files Browse the repository at this point in the history
The zigbee standard specifies that the values of section 4.13
Concentration Measurement are to be represented between 0 and 1 (section
4.13.2.1 Attributes). Further it is explained in section 4.13.2.1.1
MeasuredValue Attribute that "MeasuredValue represents the concentration
as a fraction of 1 (one)."

Because the current implementation multiplies the given MeasuredValue by
1000000 (million) the published value is not only wrong, but changes in
the inverse direction. The larger the actual measured value becomes (the
larger the denominator is), the smaller MeasuredValue becomes.

| Device (PPM) | MeasuredValue | z2m (PPM) |
|--------------|---------------|-----------|
| 800          | 0.00125       | 1250      |
| 1250         | 0.00080       | 800       |
  • Loading branch information
Eyenseo committed Jan 19, 2025
1 parent 45fa046 commit ba3f0e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/converters/fromZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ const converters1 = {
cluster: 'msCO2',
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
return {co2: Math.floor(msg.data.measuredValue * 1000000)};
return {co2: Math.floor(1 / msg.data.measuredValue)};
},
} satisfies Fz.Converter,
occupancy: {
Expand Down

0 comments on commit ba3f0e6

Please sign in to comment.