I have created an automation to open my blind in the bedroom with several conditions (between 7am and 10pm, between sunrise and and sunset, and bed not occupied for 10 minutes).
Today it failed, but I don’t understand why. The trigger was 7am in this case and it failed at the condition for sunrise/sunset.
This is the condition I have configured:
condition: sun
after: sunrise
before: sunset
In the trace log for this execution I see that it evaluated to false, but I can’t understand why, since 7am should be between those values.
@Shortie I had the same problem but recently solved it. I actually had to edit this post to correct something I previously thought. The short answer is that the “executed” time is displayed in your selected timezone but converted to UTC time when checked against the “wanted time” in the condition. So when trying to use the “trace” function to check it everything seems wrong.
The long answer is, depending on your timezone, the “executed” time could appear to be within the constraints of the “wanted time” but show false. Since I’m in CST, I originally thought I had to use an offset of -06:00:00. When I did that, the “executed” time and “wanted time” appear to be correct but the condition showed false. Then when I removed the offset the same condition appeared to be false but showed true. After trial and error, I realized that for it to make sense when viewing it in the “trace” and possibly other places that you might be seeing it in your time zone or UTC but that on the backend your timezone is changed to UTC when checking it in a condition. The offset would only be used if you want to change the condition to an earlier or later time before or after sunrise or sunset. Hopefully, I did not confuse anyone.
Now the way that I set up my choose conditions was in the order of how I wanted them checked within the same 00:00:00 to 24:59:59 same day time period. For example, sunset does not pass midnight. So when setting up the choose statement always think of it being within the constraints of a single day.
In my example, you can see that the first condition requires it to be both after sunrise AND before sunset for it to be true. When triggered while the sun is up both statements are true and the light turns on to a set kelvin temperature. The second condition handles the rest of the day which is before sunrise OR after sunset and when true the light turns on to a different kelvin temperature.
Hopefully, I explained this right, and hopefully, it helps.