but can’t figure out how to make the on and off work properly in a single rule. Worse case I can just split the on and off functions into their own rules, just wasn’t sure if I was missing something as I’m still trying to learn more about sharptools.
I am still learning but I believe that “sunset” would be the sunset for that day in time, and then “sunrise” would be also for that day in time.
So if the rule is triggered at 11:59pm sunset would be that night’s sunset that occurred a few hours prior while sunrise would be the sunrise that occurred that morning.
Once you hit 12am “sunrise” changes to be the next sunrise that will be happening within the next 4-10 hours and “sunset” would be the sunset that would be happening later that night after sunrise.
Taking a look at the rule I made (Let’s say that sunset is always 8pm and sunrise is always 6am):
If we break down the rule I made we have two triggers.
15 minutes after sunset
120 minutes before sunrise
The first time the rule is triggered would be at 8:15pm. Sunset happened at 8:00pm so the rule is true as current time (8:15pm) is after 8pm.
The second time the rule is triggered would be at 4am. Sunset is suppose to happen at 8pm, so the rule is false as the current time (4am) is before 8pm.
Okay so looks like what I said earlier is true. Here is how I tested if you want to do it yourself (my porch lights also turned on correctly when expected from my rule posted earlier in the thread).
I created this rule that is just triggered by pushing a button I then have two if blocks one for sunset and sunrise. Doing before or after is up to you, just make sure the logic makes sense to you.
For me I got the following results:
It is after sunset
It is after sunrise
So my first if block (current time is after sunset) returned true and my second if block (current time is before sunrise) returned false.
You can also see in the logs for the if block what time is used for sunset and sunrise
After midnight I’ll run it again to make sure the local sunset and sunrise values change as expected and that the if blocks return the flipped responses.
Edit: After rerunning after 12am the results were flipped:
It is before sunset
It is before sunrise