Icon template with three states

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?

The if-elif chain you have in the icon_template will halt at the first if that evaluates to true. In other words, if upstairs_study_heater is on it picks radiator-disabled. Done. It won’t matter if study_heater is also on because the if-elif already ended on the first if.

The only way it will display the radiator icon is if upstairs _study_heater is off and study_heater is on. That sounds like it may be an impossible situation because I assume if the heater is on then the sensor will also indicate on.