Less than template cover

Hi Guys,

Sorry in advance im sure this is a really simple issue but I can’t see the work out what im doing wrong and my searches haven’t populated anything related to the issue I am having.

Essentially I have a sensor that is monitoring the air quality, the output is numerical value but I would like to create a template cover that gives a more user friendly output. The following configuration seems to work when changing the value fixed output but my adaption to get it to output based on a less than value doesn’t seem to work.

any help would be greatly appreciated.

  - platform: template
    sensors:
      air_quality_cover:
        friendly_name: "Air Quality"
        value_template: >-
          {% if is_state(sensor.bedroom_monitor_air_quality <= 50) %}
            Healthy
          {% else %}
            Unhealthy
          {% endif %}
  - platform: template
    sensors:
      air_quality_cover:
        friendly_name: "Air Quality"
        value_template: >-
          {% if states('sensor.bedroom_monitor_air_quality')|float <= 50 %}
            Healthy
          {% else %}
            Unhealthy
          {% endif %}
3 Likes

Works perfectly, thank you for your help

1 Like