Configuration check won't finish with template condition

Ok… So I got this script (see below) which has a template condition. I consider it as nothing special as it would also give a proper result in the test-template screen under Developer Tools. The question marks around my head start to pop-up when I have the condition uncommented in the script and try to check my configuration under Settings > Server Controls because it keeps running for minutes. When I put it in a comment block and check the configuration again it’s finished within 2 seconds. Since I’m still rather new to Home Assistant and to templates even more I’m a bit confused if it’s my template giving this strange behaviour or something else is acting up. Would like to add that I also tried a simple template like {{ 1 == 1 }} and that also caused the long configuration check. In none of the cases where it took long I’ve seen it finish.

Hopefully someone has an idea what could cause this, because I’m not confident about restarting my RPI (default installation) with this condition uncommented :slight_smile:

alias: "Zet soundbar aan"
icon: mdi:surround-sound
description: "Zet soundbar aan (alleen als ie uit staat)"
sequence:
  - condition:
    - condition: template
      value_template: "{{ is_state('media_player.sony_soundbar', 'off') }}"
  - service: media_player.turn_on
    entity_id: media_player.sony_soundbar

SOLUTION:
As mf_social already kindly improved my script it was because of the extra line of - condition which was simply a remaining line from copying it from an automation. As it turns out you don’t need to start a condition like in an automation, that’s where I went wrong.
After that I wondered how the nested conditions would work, found a nice explanation for those interested: explanation

alias: "Zet soundbar aan"
icon: mdi:surround-sound
description: "Zet soundbar aan (alleen als ie uit staat)"
sequence:
  - condition: template
    value_template: "{{ is_state('media_player.sony_soundbar', 'off') }}"
  - service: media_player.turn_on
    entity_id: media_player.sony_soundbar
2 Likes

And this neatly encapsulates why if I need and/or combination ‘conditions’ in actions I end up writing a template (Marius’s tag line)
:man_shrugging:

Thanks! I will try this when I’m home.

Though I might reply again with my implementation in the automation where I had it in the first place. Since there it produced the same behaviour, I assume it also has to do with my writing :slight_smile:

1 Like

As you already knew, your solution was correct :smiley: Thanks for that, conditions in the different concepts are now more clear to me!

1 Like