Basically that's the question. I want to automatically open some curtains at sunrise UNLESS sunrise is earlier than 7am. In which case I want to wait until 7 and THEN open the curtains.
There will be a better solution than this, but you could setup a rule that is triggered at either 7am or sunrise, which sets the private Boolean and/or a hub variable, with a required expression that the private Boolean is false. Then in a second rule do the actions you want. You will likely want something to run overnight to reset the private boolean. Luke I said, not as near as solution as others are likely to come up with.
Edit - I could have that logic round the wrong way.... Been a long day.... Hopefully you get the idea.
I think I get it. Probably have to set the boolean a minute earlier than the trigger time to make sure it's set. Thanks. Unless someone has a simpler idea I will code this up.
But to open a curtain I have to operate an actuator, not turn on or off lights. I didn't see how I would do that. Plus, going in to room lighting reminded me why I don't use it, super overly complicated. I do appreciate the attempt to help me though.
Have a rule with both triggers and a variable that counts up on each event. On one, do nothing. On two, take action and then reset your counter.
Once that falls out of sync, it will stay out of sync... Perhaps another trigger to reset it every day if you want it to self heal after a power cut kind of scenario.
There is a way to do this but I've previously looked for the post where it was detailed and can't locate it. The answer came from either bobbyD or bravenel but it was probably two years ago shortly after I first started with Hubitat.
IIRC it revolved around looking at the tables for sunrise/sunset for your specific location. There's a way to specify a date that gets used in the rule, that will allow this to work. Apologies as this is so vague, I'll try and locate the post/solution again. I could do with finding it, as I need to use similar to ensure my curtains don't close too early in the winter.
Find the earliest sunrise for the year in your location, then:
Rule 1
Trigger:
certain time (set before earliest possible sunrise)
Actions:
Set Hub Variable False
Wait until 7AM
Set Hub Variable True
Rule 2
Trigger:
Sunrise
Actions:
Wait for expression (not event) Hub Variable True
open curtains
At sunrise if it's not yet 7AM the Hub Variable will be false and the rule will wait until it's true before opening the curtains. However if sunrise is after 7AM the rule will trigger and say 'expression already true' and open the curtains immediately
I think this is the winner. I was able to easily code this just now. We'll see how it performs tomorrow morning, but this is simple and elegant. Thanks @johnwill1. And thanks to all that weighed in. I'll mark this as the solution when it works tomorrow.
The above does an earlier of two times within Rule Machine. To do a later of two times, keep the structure the same except, but move the actions to the Else. It would be:
If Boolean true, set Boolean False
Else, Actions and set Boolean True