AirGradient Forum

Home Assistant Integration

Current integration works well and was able to detect both indoor and outdoor units.

Is it possible to add local AQI including all the correction formulas for AQI, temperature, etc? I guess most of the calculation etc takes place on the dashboard/airgradient servers but Is there any plan for adding the calculation directly in the firmware?
Also noticed outdoor you cannot get aqi at all.

Hi kan84,

As you can see from this docs page, we actually processed correction on the monitor too. But specifically for AQI, pmStandard config only applied for the display, not local server (where home assistant pull the data).

We’ll try to implement this on the next release. Thanks for the suggestion!

2 Likes

Is that something that can be done for both AQI and temperature/humidity for the external one so can use both on homeassistant

1 Like

agree, it would be great if AQI was sent to HA. At the moment I am considering to implement this logic myself in HA which seems like a needless duplication

I did but it does not match what shows on dashboard with or without correction.

Hi @kan84 ,

Could you share your progress on how you implement it? Have you follow this post Feature Request: add AQI sensor to Home Assistant integration - #8 by applesauc3?

Home assistant dashboard → Settings → Helpers Tab → Create Helper → Template → Template Sensor

Name: This will be the entity name to be used for dashboard.

State Template: (Not sure where I got it but it will not be inline with USAQI correction formula. Also not sure if it will vary for outdoor or indoor but I use this for both.

{% macro aqi(val, val_l, val_h, aqi_l, aqi_h) -%}
{{(((aqi_h-aqi_l)/(val_h - val_l) * (val - val_l)) + aqi_l)|round(0)}}
{%- endmacro %}
{% set v = states(‘sensor.eaqi_pm2_5’)|round(1) %}
{% if v <= 12.0 %}
{{aqi(v, 0, 12.0, 0, 50)}}
{% elif 12.0 < v <= 35.4 %}
{{aqi(v, 12.1, 35.4, 51, 100)}}
{% elif 35.4 < v <= 55.4 %}
{{aqi(v, 35.5, 55.4, 101, 150)}}
{% elif 55.4 < v <= 150.5 %}
{{aqi(v, 55.5, 150.4, 151, 200)}}
{% elif 150.4 < v <= 250.4 %}
{{aqi(v, 150.4, 250.4, 201, 300)}}
{% elif 250.5 < v <= 500.4 %}
{{aqi(v, 250.5, 500.4, 301, 500)}}
{% else %}
500
{% endif %}

Unit of Measurement: AQI

Device Class: (blank) If I select Air quality index, it errors out.

State Class: Measurement

Device: Whatever device name is so this entity shows under it,