Hello
I retrieve IQAir data (https://www.iqair.com/ ) via a Python script, which gives the air quality near you.
The information arrives at Gladys with an MQTT publication
As you can see on the website, there is a threshold (here 46), and depending on the threshold, there is an associated color. As long as the threshold is below 50, the associated color is green, between 50 and 100, it’s yellow, etc…
My question is: « How do I display a color based on predefined thresholds? »
Thanks in advance
Olivier
Hello @bong101 , currently this is not possible, however this would be a nice feature and not very complicated to code
We would need to create an « air quality » type in Gladys, and enter the different value thresholds. We already do this with humidity!
I will convert this post into a feature request.
Edit: It’s done!
Hello @bong101 , I’m happy to announce that @AlexTrovato has developed the feature for Co2 sensors!
It looks like this:
I just merged the PR on master, it will go out in the next version of Gladys
master ← atrovato:colored-ppm-air-quality
ouvert 10:29PM - 16 Mar 22 UTC
### Pull Request check-list
To ensure your Pull Request can be accepted as fa… st as possible, make sure to review and check all of these items:
- ~~[ ] If your changes affects code, did your write the tests?~~
- [x] Are tests passing? (`npm test` on both front/server)
- [x] Is the linter passing? (`npm run eslint` on both front/server)
- [x] Did you run prettier? (`npm run prettier` on both front/server)
- ~~[ ] If you are adding a new features/services, did you run integration comparator? (`npm run compare-translations` on front)~~
- ~~[ ] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to [the community](https://community.gladysassistant.com/) for testing before merging.~~
- ~~[ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)~~
- ~~[ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See [the GitHub repo](https://github.com/GladysAssistant/v4-website) and the [website](https://gladysassistant.com).~~
- ~~[ ] Did you add fake requests data for the demo mode (`front/src/config/demo.js`) so that the demo website is working without a backend? (if needed) See [https://demo.gladysassistant.com](https://demo.gladysassistant.com).~~
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
### Description of change
CO sensor as colored badge.
https://community.gladysassistant.com/t/type-qualite-de-lair-natif-avec-couleurs-en-fonction-de-la-valeur/7014
A little refacto to allow to enlarge easily and clearly the way to display sensor values.

It’s not yet a complete air quality management (AQI, fine particles, etc.), but it’s a first start
Good, but I think there was some confusion about the values. I don’t find the same recommendations as what we put:
Indeed, I took the reference from the website mentioned at the beginning of the topic, the ratios may not be correct.
But it should be simple to change them.
It was AQI on the site (an air quality standard), here it was ppm (amount of CO2 in the air)
I’ll change it!
For your information, this change is available in Gladys Assistant v4.8.2!
Salut à tous !
C’est lundi, pas de temps à perdre, c’est l’heure d’une nouvelle version de Gladys avec un ensemble de correctifs
Les correctifs
Les capteurs de Co2 affichent désormais une couleur en fonction de la concentration en Co2 dans l’air, selon les recommandations :
[Indice-PPM-1-1024x538]
Correction d’un bug où l’intégration Zigbee2mqtt créait des valeurs de capteurs au format “texte” dans la base de donnée (au lieu de flottants), ce qui créait des bugs sur l’agrégatio…
@bong101 Does this answer your request (For now, we only manage CO2), or would you like to have an « AQI » type in Gladys?
Good, well, it’s great in terms of reactivity.
I just restarted watchover, I’m testing and I’ll reply tomorrow.
AQI?, what is that?
bong101:
AQI?, what is that?
You’re the one who told us about it
AQI = Air Quality Index
It’s a unit of measurement for air quality, which takes into account several measures (fine particles, etc…)
Think of the AQI as a yardstick that runs from 0 to 500. The higher the AQI value, the greater the level of air pollution and the greater the health concern. For example, an AQI value of 50 or below represents good air quality, while an AQI value...
Here, @AlexTrovato has only worked on CO2, so I’m not sure if that’s your original request.
Oh yes, that’s true…
Actually, my request was more generic… a sensor that returns values, levels, and depending on the level in which the value is located, a color display. This could be used for anything, the water tank, all kinds of sensors … well, I think.
In any case, I will test this as soon as watchover has made the update
thanks
We didn’t do that generically in Gladys, we try to code everything turnkey so that it’s easy to use and works by default So the CO2 levels are in Gladys in the code (it’s not something that changes), if we want to add more (AQI for example), we will have to do the development too
VonOx
January 13, 2023, 3:32pm
14
I’ve made a PR that adds AQI + color display
master ← VonOx:aqi
ouvert 03:16PM - 13 Jan 23 UTC
+ Add AQI Sensor + Custom Value color badge
* Reorder DEVICE_FEATURE_CATEGORIES…



https://community.gladysassistant.com/t/type-qualite-de-lair-natif-avec-couleurs-en-fonction-de-la-valeur/7014?u=vonox
It’s merged into master, it will be included in the next Gladys release!
Thanks @VonOx for the PR
I tested all 6 possible states, everything is fine for me :
I’m closing this thread to free up the votes.