Automation condition not working as it should?

Hi all,
I’m new to HA and trying some simple automations to make my house a bit smarter.
What I’m trying to do, is automate my shutters, at the position of the sun, but not before a certain time.
My code:

id: '1633639623946'
alias: Rolluiken dicht avond
description: Shutters will follow the sun. Sun down -> shutters down.
  - platform: sun
    event: sunset
  - platform: time
    at: '20:00:00'
  - condition: sun
    after: sunset
  - condition: time
    after: '20:00:00'
  - scene: scene.rolluiken_dicht
mode: single

The problem I’m having, is that when one of the conditions fail the automation just doesn’t try again and stops.
Sun is down, this triggers one of the actions, but the time is 19h02 for example. condition 1 will be met, but condition 2 not. and the whole automation will just end, and doesn’t retry.

it’s quite handy that HA offers a trace in the history, but this doesn’t really help me:
(I can see that the condition fails, but I would guess that the automation would’ve been retried untill the condition would’ve been met… )

Executed: October 8, 2021, 7:02:53 PM
  __type: <class 'datetime.time'>
  repr: datetime.time(20, 0)
  __type: <class 'datetime.time'>
  repr: datetime.time(19, 2, 53, 728126)
result: false

You would have guessed wrong.

Conditions are only evaluated once after the automation has triggered.

The way your automation is written it has to be after sunset AND after 8pm.

What do you actually want?

But the way you have it the automation will “retry” again at 20:00.

And then both conditions will be satisfied and it will run the actions.

It just don’t wait for the conditions between sunset and 8pm or between 8pm and sunset.

Aha I got it! Seems fair!
Thanks a bunch for the info!

1 Like