-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CO2 value interpretation #8644
Conversation
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 |
What device do you have? Maybe it's best to also refactor that to modernExtend. |
DIY project based on nrf52840/zephyr and scd41. I would like to use modernExtend - I just don't know how to do that / where the calculations take place. But I have also not searched for documentation too much. My guess was that they somehow still make use of the function that I modified, but based on your answer that is not correct, which would mean that they convert via |
Using modern extend should be easy, see
The conversion is done here:
|
I haven't reached the point just yet where I can use the reporting feature - but I guess it makes sense that the device will be able to undo the fraction to compare the two values. |
This field is interpreted by the device and the device will have to undo the fraction to figure out if there's something to report.
Thanks! |
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.
modernExtend.ts
seems to make similar assumptions too, but I do not know how / whenscale
andchange
are used - before or after the conversion took place.