Help with a condition template

I have an automation that is running fine but i am wanting to add a condition to it so it does not fire unless it is necessary. The condition is supposed to be that the thermostat is set to away mode but it is making the automation not fire at all.

Thanks for your help

  - alias: "Ecobee Resume By Door or Window Automation Downstairs"
    trigger:
    - platform: state
      entity_id:  group.downstairs_windows_and_doors
      to: 'off'
    condition:
      - condition: template
        value_template: "{{ state_attr('climate.downstairs','preset_mode') == 'away' }}"
    action:
      - service: climate.ecobee_resume_program
        data:
          entity_id: climate.downstairs

The condition looks right to me but in your posted code you have an extra space before “group.downstairs_windows_and_doors”. I’m not sure if that would break the automation but I’d thought I’d point it out just in case.

Thanks. It woks with the extra space with no condition but not when i have the condition there. I will remove the extra space though.

Copy and paste your template in Dev Tools/Templates and check if it returns ‘True’.

Yep it did. I put it back in and it worked this time. Ecobee has been having server issues the past week. It might have been on their side. Thanks for your help everyone

1 Like

as a fyi, please note you can also use:

 condition:
      - condition: template
        value_template: >
          {{ is_state_attr('climate.downstairs','preset_mode','away') }}

I find the is_state_attr format easier to get correct, when attributes have to be quoted

the multiline notation ( using the >) saves you from dealing with the outer quotes.

Thanks. Good info to have