Ecowitt pm 2.5 aqi missing

I have added a WH41 pm2.5 to my weather station and this shows up fine in the android app.

However, I have noticed that the official Ecowitt integration is not showing the AQI values, current and 24 hrs. The pm2.5 readings do show up.is there a way of adding these readings in the integration ormaybe some means of calculating using my WS69 and WH41 sensor values in HA?

I have a WH45 and I’m pretty sure the android app is calculating the AQI based off the raw pm2.5 values which is why you don’t see them in HA since they don’t technically exist.

You can use this template sensor to get the AQI for pm2.5 into HA:

indoor_aqi:
        friendly_name: 'Indoor AQI'
        unique_id: indoor_aqi
        # Set this sensor to be the AQI value.
        #
        # Code translated from JavaScript found at:
        # https://docs.google.com/document/d/15ijz94dXJ-YAZLi9iZ_RaBwrZ4KtYeCy08goGBwnbCU/edit#
        value_template: >
          {% macro calcAQI(Cp, Ih, Il, BPh, BPl) -%}
            {{ (((Ih - Il)/(BPh - BPl)) * (Cp - BPl) + Il)|round }}
          {%- endmacro %}
          {% set pm25 = states('sensor.easyweatherpro_v5_1_1_wh45_pm2_5_co2')|float(0) %}
          {% if pm25 > 1000 %}
            invalid
          {% elif pm25 > 350.5 %}
            {{ calcAQI(pm25, 500.0, 401.0, 500.0, 350.5) }}
          {% elif pm25 > 250.5 %}
            {{ calcAQI(pm25, 400.0, 301.0, 350.4, 250.5) }}
          {% elif pm25 > 150.5 %}
            {{ calcAQI(pm25, 300.0, 201.0, 250.4, 150.5) }}
          {% elif pm25 > 55.5 %}
            {{ calcAQI(pm25, 200.0, 151.0, 150.4, 55.5) }}
          {% elif pm25 > 35.5 %}
            {{ calcAQI(pm25, 150.0, 101.0, 55.4, 35.5) }}
          {% elif pm25 > 12.1 %}
            {{ calcAQI(pm25, 100.0, 51.0, 35.4, 12.1) }}
          {% elif pm25 >= 0.0 %}
            {{ calcAQI(pm25, 50.0, 0.0, 12.0, 0.0) }}
          {% else %}
            invalid
          {% endif %}
        unit_of_measurement: "AQI"
        availability_template: >-
          {{ states('sensor.easyweatherpro_v5_1_1_wh45_pm2_5_co2') not in ['none', 'unknown', 'unavailable'] }}

Once that is working you can use this statistics sesnor(or the average integration from HACS) to get the 24h average:

  - platform: statistics
    name: "Average Indoor AQI (24h)"
    entity_id: sensor.indoor_aqi
    state_characteristic: mean
    max_age:
      hours: 23.98

Thanks. That worked. I am interested in your images above too. Are those graphs in HA?

Glad you got it working! The graph is apex-charts which is a custom thing from HACS but I can help you get it all working just not right this moment. I’ll respond when I have a chance to get it all together and write up some instructions.

Sorry for the delay, here is the code for the above card.

https://github.com/afxefx/HA/blob/ed579a007f62a53456ac7b9708b461399371d645/aqi_card.yaml

I use another custom card called Swipe Card available via HACS to allow me to swipe between multiple cards to conserve space:

https://github.com/bramkragten/swipe-card

Lastly, here are the backgrounds that I have placed in www/gauge to use for the backgrounds. These are courtesy of @GlennHA who made them originally.

https://github.com/afxefx/HA/blob/ed579a007f62a53456ac7b9708b461399371d645/gauge_backgrounds.zip

You’ll notice there are two types of graphs, apex-charts and mini-graph-card, because I am in the process of migrating to apex-charts from mini-graph-card. Here is a full screenshot of the page with the charts expanded:

2 Likes

Thanks for thise

1 Like