Seen 2017 similar inquiry with no solution.
I would like to trigger blinds closing within i.e. 45 minutes before sunset, if the light sensor triggers. So say sunset at 16:55, but due to rain the light sensor triggers 16:45, it is within those 45 minutes and such allows to trigger to close the blinds. Ideal to wait five minutes to avoid a dark cloud, but I’m not even at step one.
“Offset” to my understanding (and how my automation triggered) 16:55, offset -00:45, works at 16:10. But not at 16:45.
The light sensor (from shellyparts) triggers simply 1=daylight, 2=dark.
So I would like to set trigger something like if lightsensor triggers dark AND sunset is within 45 minutes
Though I tend to think this is a bit more complex than a simple if/and
Any ideas?
Post what yaml you have, properly formatted, and we’ll help you fix it. You need two triggers (one for light and one for sunset with offset) and two conditions, doing basically the same. That is because both conditions can become true in any order, and you want them both to be true at the same time for the action to happen.
Thanks @petro - Immediately tried and it worked “out of the box”. I hope it’ll work the same in real life from now on. For Dummies: Why the offset “after” instead of “before”? Using
- condition: sun
before: sunset
before_offset: "00:45:00"
it didn’t work reliably. I also tried the Sunset as trigger and the light sensor and the 45 minutes before as conditions.
I just happen to fail to understand why it workd after:sunset/after_offset. (with negative offset)? Simply didn’t get to the idea to use after (with a negative value).
@Edwin_D As just written, I tried several variants, all not doing what I expected them to do. The “after” seemingly working with a negative offset doing the trick…?
I had a sunset today 20:11. I covered the sensor at 19:33 and after a three minute delay it closed the blind at 19:36. Just as I wanted for several weeks trying over and again (but no “after”).
My last semi-functioning try worked only if minimum 45 minutes prior sunset - but then also in the morning… I think it might have to do with the ''after_offset: “-00:45:00”``, though I’m still puzzled, trying to understand what the difference is.
@evugar@CCOSTAN you had the issue back in 2017, just in case this might help you too still
[edit: Replacement of the deleted reply which I wrote German, whoopsie.]
The semantics of this condition can be confusing because of the reference points for the time spans. Take a minute to look at the graphic provided in the docs for this condition. The after configuration variable with a negative offset includes the span of time from the offset until midnight. The before configuration variable without an offset includes the span of time from midnight until the event. Combining them as petro has shown yields a time span that contains the times that are common to both of the original spans.
Just FYI advance, didn’t work yesterday, no closing at sunset, light sensor was “off” more than 90 minutes prior (Shelly shows) thanks to incoming rain, positively off 45 minutes before sunset. Light rain started after sunset, but awning had remained open and had to be closed manually
Will need to look into it. And tend to make two automations, one for the light sensor and one for the sunset
Hello @petro, I did post my need in the initial inquiry here
And yes, I may fundamentally misunderstand, that’s why I ask here
If you want he automation to run anytime between those times, you need to add those triggers.
That’s what I need.
The traces are not available, as there was a HA update I think, which I believe disrupted the tracing, it only shows last night, when it did work. I only recognized in the morning “after” when the awning was still out (and wet). Fortunately a sunny day.
Create a duplicate Automaton to test the logic. Remove the conditions to start, and when the actions are successful, add the conditions back. Take it one step at time to debug.
You can also manually trigger the Automation to view the Traces
Exactly my approach now
And reason I wrote Just FYI advance
It triggered on testing perfectly, yesterday too. But failed two days ago. So it’s a bit difficult to claim the reasoning. Especially as I am novice and no pro.