Condition between a certain time and Sunrise not working as expected?

Maybe this has been answered before, but when I search this forum I can't find a clear answer.

I have a rule where I want to turn on the lights in the morning between 6.00 and Sunrise +30.
However, since I live far up north, the Sunrise +30 will occur before 6.00 in the summer and then I don't want to turn on the lights since there is no need for that.

When I create an IF condition for this is doesn't seeem to work though, since the conditions says that the time it is True even though it isn't.
It works fine though when Sunrise +30 occurs after 6.00.
What am I missing?

Does the IF condition apply for the Sunrise +30 tomorrow (the next day)?
If so, how do I create RM rule that works both for Sunrise +30 before and after 6.00?

Example of rule:

Sunrise and Sunset time:

I can't use the simplified lighting app since I have some other conditions and triggers in my actual rule.

I can only imagine it is detecting sunrise as the next day, I guess that is required for other rules like time being between sunset and sunrise... I'll have to leave that one to HE support or other more experienced users than me. I know there are some topics around that talk about when the updated times for sunrise and sunset are set, but not sure whether that would come into play here.

Only solution I can think of, which isn't rock solid, is to use a virtual switch (or variable) to represent that the sun is down, setting up one rule to turn it on at sunset and a second rule to turn it off at sunrise + 30. You can then use that switch in your rule, e.g. IF Virtual Switch is on THEN turn on your lights.

Thinking about it some more, this would make a good built-in feature, unless it already exists, allowing users to configure what they consider "sun down" and "sun up", then referring to those in rules and other apps... Either that, or a custom app or driver would be easy enough to setup I would expect, at least a simple one to start with...

Instead of "and" use "or" and don't use the trigger Event, since this is optional, when using if-conditions.
And additionaly I would put in, that the lights are turned of, resulting in the following:

Trigger: None

Action: If lights are off an time 6:00 or lights are off and sunrise + 30 then turn in lights.

I've noticed that if you start looking at a time until sunrise but sunrise is before that time then it looks to sunrise tomorrow and will always be true so you need to adjust the start time so it is always before sunrise in your area for it to work correctly.

@bravenel,

Would the issue described above also be addressed by the fix you mention here, slated for a future release, or do you think it is more a case of changing the rule definition?

No this is a separate issue above.

Sunrise + an offset is fired by the system sunrise event. If sunrise + 30 is before 6:00 am, then what is shown above would mean starting at 6:00 am today, and until 30 minutes after sunrise tomorrow. Between two times is always interpreted as between the time starting at the first time, and running until the second time.

I have a rule that does something like this, same ballpark. It's called Dawn, and is meaningful in the winter but not the summer (reverse situation). It has a condition that it only works between 5:00 am and Sunrise:

IF(Time between Sunrise and 5:00) Exit rule.

It happens to be the case that where I live 5:00 AM is earlier than the earliest sunrise of the year. The action I'm interested is setting a mode called Dawn at 6:00, but not if 6:00 is after sunrise. So you can see the similarity.

So the issue in the OP above is a logic problem, easily solved. I guess his case is the same as mine, a light that only be turned on in the winter, not the summer. Similar solution would work. Exit the rule if the time is between sunrise + 30 and 4:00 AM (a time sure to be before the earliest sunrise of the year). Then if it gets beyond that test, turn on the light at 6:00 and off at sunrise + 30. This guarantees that sunrise + 30 is actually after 6:00, and that nothing happens unless that is true.

3 Likes

So in this case @Chewbacca should add an action at the beginning of the rule saying:

IF Time between Sunrise +30 and 6:05 THEN Exit Rule

Using 6:05 just to account for any boundary issues, unless that is not necessary... ?

No, that won't work. The second time has to always be before the first time, no matter what time of year, i.e, a time before the earliest sunrise of the year. That window of opportunity closes once sunrise is earlier than 6:00, or sunrise+30 is earlier than 6:00, depending on how he wants it to work.

It could be between sunrise+30 and 00:01 (one minute after midnight. Ha, this rule wouldn't work above the arctic circle. In effect, we're defining a window of time where turning the light on at 6:00 means where doing that before the time we want to turn it off.

Ok, I probably need to play with it myself to understand it some more, night leave it for @Chewbacca to do that for now and see what works. Thanks for the tips Bruce.

Maybe it's confusing that I have the 'restriction' backwards.

In Basic Rule:

This rule would only run if sunrise is after 5:30 AM. Once it's before that, the restriction would not allow it to run. On that last day in the spring, the light would turn on at 6:00, and then off right away. The next day, no light at all.

1 Like

So when Sunrise + 30 is before 6, the restriction stops the rule firing, ok, now I get it. Nice...

Not sure if you read my earlier post, but would you consider a flag or concept of some kind to indicate "the sun is up"? Allowing users to configure there own logic to determine it, but then rules could refer to it rather than needing to implement the logic in the rule? I haven't described that very well...

I guess I'm thinking something along the lines of modes.

In other apps, not Basic Rule (yet), you can use time variables. Those variables could be set by a simple RM rule. Then you get what you're describing. Variables called "sunup", and "sundown", for example. You could even make them seasonal, as timings are naturally somewhat different in the winter when sunrise is so late...

And it would only be a very simple step beyond that to set a switch, in another rule. That sounds good to me, thanks again.

I had also in the back of my mind that you could expand on the time-based logic and start to incorporate light sensors, where you may have cloud-cover in the late afternoon / evening, perhaps closing blinds and alike earlier than sunset + offset. But again, that could still be done in RM.