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

Icon template with three states

$
0
0

@Brett_Hales wrote:

Hi,
I’m struggling with getting my mdi icons working within a value template with three different states (ie. mdi:radiator-disabled, mdi:radiator or mdi:radiator-off).

I tried this:-

      solar_upstairs_study_heater_on:
        entity_id:
          - binary_sensor.upstairs_study_heater
        value_template: >-
          {{ is_state("binary_sensor.upstairs_study_heater", "on") 
        icon_template: >-
          {% if is_state("binary_sensor.upstairs_study_heater", "on") %}
            mdi:radiator-disabled
          {% elif is_state("switch.study_heater", "on") %}
            mdi:radiator
          {% else %}
            mdi:radiator-off
          {% endif %}

My problem is that the icon never turns to ‘mdi:radiator’ mode even when the switch.study_heater is on.

I expect that I need to add the state of the switch in the value_template section, I’ve tried the ‘OR’ below however syntax is incorrect.

      solar_upstairs_study_heater_on:
        entity_id:
          - binary_sensor.upstairs_study_heater
        value_template: >-
          {{ is_state("binary_sensor.upstairs_study_heater", "on") **OR**
          is_state("switch.study_heater", "on") }}
        icon_template: >-
          {% if is_state("binary_sensor.upstairs_study_heater", "on") %}
            mdi:radiator-disabled
          {% elif is_state("switch.study_heater", "on") %}
            mdi:radiator
          {% else %}
            mdi:radiator-off
          {% endif %}

Can anybody help?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 99017

Trending Articles



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