The WAQI integration reports air quality data by a custom metric - AQI. Instead, other sensors report particulate matter using the standard measurements in the air_quality component:
I agree this would be nice. In the meantime, I developed a template sensor based on the WAQI integration to pull the PM2.5 value and convert it from AQI to µg/m³ based on this formula: PM2.5 to AQI Conversion / Mike Bostock | Observable, which is hopefully correct. Perhaps this will help someone else!
- sensor:
- name: "My Location WAQI PM <2.5µm"
unique_id: waqi_my_location_pm_2_5um
state: >
{# Adapted from https://observablehq.com/@mbostock/pm25-to-aqi #}
{% macro lerp(ylo, yhi, xlo, xhi, x) -%}
{{ ((x - xlo) / (xhi - xlo)) * (yhi - ylo) + ylo }}
{%- endmacro %}
{% macro aqi_pm25(aqi) -%}
{% set a = (aqi | round) %}
{% if a < 0 %}
{# values below 0 are considered beyond AQI #}
{% set c = 0 %}
{% elif a <= 50 %}
{% set c = lerp(0.0, 12.0, 0, 50, a) %}
{% elif a <= 100 %}
{% set c = lerp(12.1, 35.4, 51, 100, a) %}
{% elif a <= 150 %}
{% set c = lerp(35.5, 55.4, 101, 150, a) %}
{% elif a <= 200 %}
{% set c = lerp(55.5, 150.4, 151, 200, a) %}
{% elif a <= 300 %}
{% set c = lerp(150.5, 250.4, 201, 300, a) %}
{% elif a <= 400 %}
{% set c = lerp(250.5, 350.4, 301, 400, a) %}
{% elif a <= 500 %}
{% set c = lerp(350.5, 500.4, 401, 500, a) %}
{% else %}
{# values above 500 are considered beyond AQI #}
{% set c = 500 %}
{% endif %}
{{ ((10 * float(c)) / 10) | round(2, 'floor') }}
{%- endmacro %}
{{ aqi_pm25(state_attr('sensor.waqi_my_location', 'pm_2_5') | int) }}
icon: mdi:chemical-weapon
unit_of_measurement: µg/m³