Help with template issue

Hi,

Just wondering if someone wil be able to help we out with the below. I am trying to create a template which will tell me when all the of my stats are in an off state. This is my first time doing a template so not really sure what i’m at. When I enter the below in the template in developer tools it works but not when I put into my configuration.yaml.

# Determine when all upstair stats are off #
binary_sensor:
  - platform: template
    sensors:
      underfloor_stats_off:
        value_template: >-
         {% if is_state ('climate.wardrobe_stat' , 'off') and is_state ('climate.upstairs_hall_stat', 'off') and is_state ('climate.master_bathroom_stat', 'off') and is_state ('climate.main_bathroom_stat', 'off') and is_state ('climate.hot_press_stat', 'off') %}
             Yes
          {% else %}
              No
          {% endif %}

Thanks for the help

# Determine when all upstair stats are off #
binary_sensor:
  - platform: template
    sensors:
      underfloor_stats_off:
        value_template: >-
          {{ expand('climate.wardrobe_stat' , 'climate.upstairs_hall_stat', 'climate.master_bathroom_stat', 'climate.main_bathroom_stat', 'climate.hot_press_stat')
            | selectattr('state', 'eq', 'off') | list | count == 5 }}

It’s a binary_sensor so it’s sufficient for the template to report true or false.

Hi Taras,

Thanks so much. That worked great.

Hi,

I need to use the hvac_action attribute to see when it shows heating instead of the state as I need to know when the stats are in idle or off mode. With the state attribute when in idle it still shows heat. I have tried the below but it just gives me a date back. Sorry about this still learning. Any help would be great.

# Determine when all upstair stats are off #
binary_sensor:
  - platform: template
    sensors:
      underfloor_stats_off:
        value_template: >-
          {{ expand('climate.wardrobe_stat' , 'climate.upstairs_hall_stat', 'climate.master_bathroom_stat', 'climate.main_bathroom_stat', 'climate.hot_press_stat')
            | selectattr('attributes.hvac_action', 'eq', 'heating') | list | count == 5 }}

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

# Determine when all upstair stats are off or idle #
binary_sensor:
  - platform: template
    sensors:
      underfloor_stats_off:
        value_template: >-
          {{ expand('climate.wardrobe_stat' , 'climate.upstairs_hall_stat', 'climate.master_bathroom_stat', 'climate.main_bathroom_stat', 'climate.hot_press_stat')
            | selectattr('state', 'in', ['off', 'idle']) | list | count == 5 }}