Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106100

Climate template help required

$
0
0

I have built an outdoor air quality monitor using an SDS011 and ESPhome. The sensor works great but I would like to show the particulate index for each of the 2 PM readings. I have copied/pasted and tweaked the following template but whenever I go above the 1st level on either it doesn’t display anything. It looks correct to my eyes. This is in my sensor.yaml file.

- platform: template
  sensors:
      air_quality_pm10:
        friendly_name: 'Air Quality PM 10'
        value_template: >-
          {% if states('sensor.particulate_matter_10_0um_concentration') | float <= 16 %}Good
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 17 | float > 33 %}Good
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 34 | float > 50 %}Good
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 51 | float > 58 %}Fair
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 59| float > 66 %}Fair
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 67| float > 75 %}Fair
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 76| float > 83 %}Poor
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 84| float > 91 %}Poor
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float <= 92| float > 100 %}Poor
          {% elif states('sensor.particulate_matter_10_0um_concentration') | float > 101 %}Very Poor
          {% endif %}
        entity_id: sensor.pm_10_concentration_sds011

      air_quality_pm25:
        friendly_name: 'Air Quality PM 2.5'
        value_template: >-
          {% if states('sensor.particulate_matter_2_5um_concentration') | float <= 11 %}Good
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 12 | float > 23 %}Good
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 24 | float > 35 %}Good
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 36 | float > 41 %}Fair
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 42 | float > 47 %}Fair
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 48 | float > 53 %}Fair
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 54 | float > 58 %}Poor
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 59 | float > 64 %}Poor
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float <= 67 | float > 70 %}Poor
          {% elif states('sensor.particulate_matter_2_5um_concentration') | float > 71 %}Very Poor
          {% endif %}
        entity_id: sensor.pm_25_concentration_sds011

In the template editor I see true or false depending on the values but the template sensor does not work.

I know I could cut out a few lines to simplify it but it should work either way.

Pics

good bad

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 106100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>