Sunrise is bugged

Rule machine 4.0

Time (checked on device) is now7:03, a good time after sunrise (05.42 according to device)
It still evaluates as true.

I also made a new rule with ONLY Between X and sunrise +5 and it still evaluates to true.
Could it be that rule machine evaluates Sunrise without considering the 24h format and compares to 17:42? Will check rule again at 17:50 to see what it evaluates to...

Anyway, the evaluation is clearly faulty, and juiding from the forums it has been so for a while?
Has any progress been made on this? It's a fairly important feature for my lighting rules to work.

Appreciate any input on this matter :slight_smile:


So sunrise is at 5:42? Your condition is, then, effectively "between 5:55 and 5:42," so the evaluation of "TRUE" is correct under the convention that "is between" is not a commutative operator and the order matters: the time of the left must be earlier than the time on the right. Rule Machine is therefore spanning midnight and evaluating 5:42 of the next day, causing this behavior. (By the way, I haven't seen many posts about sunrise/sunset problems except those surrounding Daylight Saving Time and similar summer/winter time changes, with the behavior fixing itself by the next day. Also, I use a 24-hour clock on Hubitat and have similar conditions set up; I do not have any problems here.)

You may be able to work around this issue in a few ways. For lighting automations, I personally use modes. I have "Morning," "Day," "Evening," and "Night" modes (plus a new "Cloudy" mode I use as an alternative to "Day" when I need more indoor light). This eliminates the need for me to use time-based conditions for lighting automations/apps. I think this setup is pretty common. If you prefer time, however, you can probably find a creative workaround. One thing I could think of is adding another condition, like "Time between sunrise and 23:59," which will be True when sunrise for that day has already happened and false otherwise; you can combine that with other conditions as needed for your logic to arrive at the truth value you want for whether the "between" time is capturing a time period within the same day.


Here's a previous discussion on this topic that you may find helpful


Thank you for a quick answer.

I realize what's happening. I just don't think it is very intuitive that Sunrise evaluates to different DateTimes in the first and second expression in my original post.

For example

It's 18.04 here...

I did a search on Sunrise on the forums and got a lot of hits with people seeming to have problems,
but looking back It's spanning a few years so maybe it's not very common.

And it may not be bugged (harshly said) but it's kinda quirky and you really have to think about how you set up your rules. It will also force my to change the rules depending on when the sun goes up in the day, which kind of defeats the purpose of trying to check for Sunrise. I'll take a look at your suggestions and create a workaround using modes. Thank you.