Skip to content

Add VOC and CO2 string sensors - #48

Draft
iomartin wants to merge 3 commits into
Airthings:mainfrom
iomartin:main
Draft

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

Conversation

@iomartin

@iomartin iomartin commented Nov 3, 2024

Copy link
Copy Markdown

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

baudneo commented Feb 4, 2025

Copy link
Copy Markdown

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
Copy Markdown

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.

Comment thread airthings_ble/const.py
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")

Copy link
Copy Markdown

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")

Comment thread airthings_ble/parser.py
CHAR_UUID_WAVE_PLUS_DATA,
CHAR_UUID_WAVEMINI_DATA,
CO2_CRITICAL,
CO2_EXTREMELLY_HIGH,

Copy link
Copy Markdown

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,

Comment thread airthings_ble/parser.py
co2_level = CO2_HIGH[2]
elif data <= CO2_VERY_HIGH[1]:
co2_level = CO2_VERY_HIGH[2]
elif data <= CO2_EXTREMELLY_HIGH[1]:

Copy link
Copy Markdown

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]:

Comment thread airthings_ble/parser.py
elif data <= CO2_VERY_HIGH[1]:
co2_level = CO2_VERY_HIGH[2]
elif data <= CO2_EXTREMELLY_HIGH[1]:
co2_level = CO2_EXTREMELLY_HIGH[2]

Copy link
Copy Markdown

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]

@LaStrada

Copy link
Copy Markdown
Member

It was decided to not include too many things like this in Home Assistant. I think we can still add this, and it's up to HA to include it or not.

I think we need to do this a bit differently, we can actually fetch this information from the device itself, at least for Wave Plus/Radon/Mini. This can be really helpful for the new custom threshold feature in the Airthings app. Then it will reflect the same thresholds set by the user in the app. I need some time to think about this 🤔

I'll keep the PR open, and I'll revisit this when I have time.

@LaStrada
LaStrada marked this pull request as draft April 10, 2026 08:23
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.

5 participants