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,