Closed xbgmsharp closed 2 years ago
Hello
Would it be nice to integrate the Dyson Calculated PM2.5 AQI. The following template sensors works fine.
- platform: template sensors: dyson_calc_aqi: friendly_name: "Dyson Calculated PM2.5 AQI" unit_of_measurement: AQI unique_id: dypson_tp_04_calc_aqi # https://community.home-assistant.io/t/purpleair-air-quality-sensor/146588 # https://aarongodfrey.dev/home%20automation/dyson-tp04-integration/#calculating-aqi-based-on-pm25 value_template: > {% macro calcAQI(Cp, Ih, Il, BPh, BPl) -%} {{ (((Ih - Il)/(BPh - BPl)) * (Cp - BPl) + Il)|round }} {%- endmacro %} {% if (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 1000 %} invalid {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 350.5 %} {{ calcAQI((state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float), 500.0, 401.0, 500.0, 350.5) }} {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 250.5 %} {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 250.5 %} {{ calcAQI((state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float), 400.0, 301.0, 350.4, 250.5) }} {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 150.5 %} {{ calcAQI((state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float), 300.0, 201.0, 250.4, 150.5) }} {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 55.5 %} {{ calcAQI((state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float), 200.0, 151.0, 150.4, 55.5) }} {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 35.5 %} {{ calcAQI((state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float), 150.0, 101.0, 55.4, 35.5) }} {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) > 12.1 %} {{ calcAQI((state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float), 100.0, 51.0, 35.4, 12.1) }} {% elif (state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float) >= 0.0 %} {{ calcAQI((state_attr("air_quality.pure_hot_cool_air_quality", "particulate_matter_2_5")|float), 50.0, 0.0, 12.0, 0.0) }} {% else %} invalid {% endif %}
Thanks
It's added to the 0.17 roadmap, thanks for the macro
Hello
Would it be nice to integrate the Dyson Calculated PM2.5 AQI. The following template sensors works fine.
Thanks