Skip to content

Comments

Add VOC and CO2 string sensors#48

Open
iomartin wants to merge 3 commits intoAirthings:mainfrom
iomartin:main
Open

Add VOC and CO2 string sensors#48
iomartin wants to merge 3 commits intoAirthings:mainfrom
iomartin:main

Conversation

@iomartin
Copy link

@iomartin iomartin commented Nov 3, 2024

It is very convenient to have the radon sensors that translate the numeric value into a string ("very low", "low", etc.). As an user, I not necessarily know what are reasonable ranges for the measurements and having these strings makes it easy to know at a glance if I should take action or not.

This is true for VOC and CO2 as well, but the library (and HA) do not have string states for them, only the numeric values. So this PR adds two new sensors (for devices that support it), which are string states for VOC and CO2. The ranges were obtained directly from the Airthings website (CO2, VOC). I copied them almost verbatim, except for the CO2 ranges 0-249 and 5000-39999, which are missing from the Airthings website (I just extrapolate to names that seemed reasonable). I want to make clear that this PR is not my personal endorsement for these ranges, I know nothing about what constitutes good and bad VOC and CO2 levels.

Also, I did not test the part that goes through _get_service_characteristics(), as the pytests do not go through that function, I just followed what is done for the radon levels. If the maintainers can easily check that this is correct, that would be great.

If this gets approved and merged, then I will work in the HA part to expose these them as new entities.

The next commit will add new level names for CO2 and VOC, so make
clear that these ranges are specific to radon levels.
This is similar to the Radon level strings, but for VOC.

The levels and descriptions were taken from [1]. I merely copied the
ranges provided by Airthings and do not claim that they are reasonable,
accurate or otherwise.

This is convenient as an end-user has no idea what are acceptable
measurements, giving them a text sensor makes it easier to spot
problems.

[1]: https://www.airthings.com/en-ca/contaminants/what-is-voc
This is similar to the Radon level strings, but for CO2.

The levels and descriptions were taken from [1]. I merely copied the
ranges provided by Airthings and do not claim that they are reasonable,
accurate or otherwise.

This is convenient as an end-user has no idea what are acceptable
measurements, giving them a text sensor makes it easier to spot
problems.

[1]: https://www.airthings.com/en-ca/contaminants/what-is-carbon-dioxide
@baudneo
Copy link

baudneo commented Feb 4, 2025

I vote for this. This is the first thing I did after adding the airthings devices. I had to use template sensors, having them from source would be great.

@LouisStAmour
Copy link

There's a typo in the PR, "extremelly" should be 'extremely'. I'm also not sure how translations might be handled. I should clarify, I've no involvement in any of these products, just bought a few AirThings BLE devices and looking to capture data.

CO2_INDOOR_NORMAL = (400, 999, "indoor normal")
CO2_HIGH = (1000, 1999, "high")
CO2_VERY_HIGH = (2000, 4999, "very high")
CO2_EXTREMELLY_HIGH = (5000, 39999, "extremelly high")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CO2_EXTREMELLY_HIGH = (5000, 39999, "extremelly high")
CO2_EXTREMELY_HIGH = (5000, 39999, "extremely high")

CHAR_UUID_WAVE_PLUS_DATA,
CHAR_UUID_WAVEMINI_DATA,
CO2_CRITICAL,
CO2_EXTREMELLY_HIGH,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CO2_EXTREMELLY_HIGH,
CO2_EXTREMELY_HIGH,

co2_level = CO2_HIGH[2]
elif data <= CO2_VERY_HIGH[1]:
co2_level = CO2_VERY_HIGH[2]
elif data <= CO2_EXTREMELLY_HIGH[1]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif data <= CO2_EXTREMELLY_HIGH[1]:
elif data <= CO2_EXTREMELY_HIGH[1]:

elif data <= CO2_VERY_HIGH[1]:
co2_level = CO2_VERY_HIGH[2]
elif data <= CO2_EXTREMELLY_HIGH[1]:
co2_level = CO2_EXTREMELLY_HIGH[2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
co2_level = CO2_EXTREMELLY_HIGH[2]
co2_level = CO2_EXTREMELY_HIGH[2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants