I am trying to create a simple automation, which somehow drives me crazy. I know I must have a stupidly simple logic error in my thinking, so I need to ask you all for help. Almost ashamed…
I am trying to do following: Activate a scene, 30 minutes after sunrise but not before 8 am.
This is my current automation:
- id: '1607517700258'
alias: Tagprofil
description: ''
trigger:
- platform: sun
event: sunrise
offset: +00:30:00
condition:
- condition: time
after: 08:00:00
action:
- scene: scene.tag
mode: single
Sunrise currently is at 07:23 am, so it triggers the automation at 7:53, since the condition is “After 08:00 am” it doesn’t start…I get that. So I also tried the other way around. Use 8 AM and sunrise as condition, but it also didn’t start.
Then I tried to add the repeat until action with until defined as 08:00 am. Also same result…
Because it doesn’t work… I thought it should be as simple as this, but my blinds don’t open.
So yes…that is what I am trying to do. If you think it all should be ok like this, I will change it back to this (tried some other things with repeat until today) and will see again tomorrow.
So just for my understanding: If the event gets triggered let’s say at 07:55:00, but the condition is not met, will the automation stay in a “wait” kinda mode until it meets the condition and then execute? Or does it just abort if the condition is not met?
I am assuming the first, if so…then I will try again.
I want it to wait until 08:00 am and then activate the scene.
That is why I also tried adding an action:
repeat until time =08:00:00
Should I modify the repeat action to say repeat until 08:00:01? My concern, or thought is…how often does it then trigger the same action within that 1 second time frame? Or should I define another repeat action…
To paraphrase your original question is it “Open the blinds at half an hour after sunrise or at 08:00 whichever is the earlier?” If so, as Triggers are Or then simply remove the Condition and add a time event to the Trigger. This does have the inelegant effect of firing the automation twice.
Dependant upon how your script works this may not be an issue for blinds. If it is, there are a few workarounds search “for triggering an automation only once a day”. Another approach would set up two automations, one for open the blinds at sunrise but not if it is after 08:00 and a second for open the blinds at 08:00 but not if it is after sunrise.
Thank you guys. I knew it wasn’t much, it was me getting to understand the mechanism a bit better. With the solutions you offered I have my issue sorted.
It is always the same when coding…make sure you have the problem/question right. That is where I had my logic error…the “OR” in the trigger event…
The second condition “sun.above_horizon” actually doesn’t work. The sun rises here at 7:23 but is not above_horizon until 8:30 or so. So it actually makes sense it didn’t work today… Will try with this tomorrow…according to my logic this must work…
- id: '1607517700258'
alias: Tagprofil
description: ''
trigger:
- platform: sun
event: sunrise
offset: +00:30:00
- platform: time
at: 08:00:00
condition:
- condition: time
after: 07:59:59
- condition: sun
after: sunrise
after_offset: +00:30:00
action:
- scene: scene.tag
mode: single
I had an incredibly stupid mistake… I checked the sensor state of the sun, to see that sunrise here is at 7:35 AM… what I did not do was check the Time Zone. Apparently the time zone it reports it in is GMT or so, or Winter Time offset does not show…well anyway… I guess you know where I am getting at…
I was off by one hour, here is me sitting at 08:15:00…being annoyed that my automation doesn’t work, well…just wait 14 minutes more…sunrise and also above_horizon happens at 08:29 here…
So basically…it all worked ok after the first tips here, I was just too much into only looking at numbers instead of simply outside… I could have seen that the sun doesn’t rise at 7:30…I mean…that is a pretty obvious clue when looking out the windows… Ok my excuse (or at least a try for an excuse)…I use the automation to control (most) of my blinds, so it was dark inside…well besides that one blind which always opens earlier…and…oh well…no excuse…just me being stupid…
Anyhow…thanks again…all my mysteries are solved and everything works correctly.