Automation action if statement

Hi all,

So I’m starting to learn quite a bit from the tutorials, and the community. However I got stuck at one point.
I have several automations to open and close my blinds. However, at version 0.95 the open and closed are inverted (swapped).

To detect this I want to check the status of my blinds at 1AM, the state they have at that moment (they will be open for sure during the night) represents if I have to set my invert boolean.

The code:

# Determine if screens are inverted or not
- id: '5'
  alias: Screens inverted
  trigger:
  - at: 01:00:00
    platform: time
  condition: []
  action:
    service_template: >
      {% if states('binary_sensor.screen_0_floor_back_down') == 'on' and states('binary_sensor.screen_0_floor_front_down') == 'on' and states('binary_sensor.screen_0_floor_side_down') == 'on' %}
        input_boolean.turn_on
      {% else %}
        input_boolean.turn_off
      {% endif %}
    data: 
      entity_id: input_boolean.screens_inverted

However this does not work, I know I can set conditions in actions but the way above is more readable for me. Unfortunately the input_boolean.screens_inverted does not change at all, can someone give a bit of advice?

Thanks.

To better understand: is the state always inverted (since 0.95) or just sometimes?

Since 0.95. In 0.94 everything worked fine. There’s already a thread at github covering this topic.

Hmmz. According to the docs there should be parentheses around your time ‘01:00:00’. If that doesn’t help: can you verify if your automation is turned on in the UI? What happens if you execute the automation from the UI? It looks fine to me actually.

Honestly, I checked it by executing it from the UI, that didn’t work :frowning:
I created the automation first using the automation wizard in HA itself, tweaked afterwards, it came with this setup for time and platform.

It triggered at 23:00:00 UTC+0, which is basically 1:00:00 AM in my time-zone (UTC+2). So it fired right away.
My thoughts are the if statements with the service_template are incorrect, but I don’t see which part is incorrect.

# Determine if screens are inverted or not
- id: '5'
  alias: Screens inverted
  trigger:
  - at: 01:00:00
    platform: time
  condition: []
  action:
  - service: input_boolean.turn_off
    data: 
      entity_id: input_boolean.screens_inverted
  - condition: state
    entity_id: binary_sensor.screen_0_floor_back_down
    state: 'on'
  - delay:
      seconds: 5
  - service: input_boolean.turn_on
#    service_template: >
#      {% if states('binary_sensor.screen_0_floor_back_down') == 'on' and states('binary_sensor.screen_0_floor_front_down') == 'on' and states('binary_sensor.screen_0_floor_side_down') == 'on' %}
#        input_boolean.turn_on
#      {% else %}
#        input_boolean.turn_off
#      {% endif %}
    data: 
      entity_id: input_boolean.screens_inverted

Got it working with the above, still figuring why the if else does not work. If else makes more sense here.

Anyone knows why the if statement didn’t work?