Trouble with Between 2 times

At this point I don't know if I am not understanding or looking at a bug.
Here is the rule, stripped down that demonstrates the problem.

If I run rule actions the spots turn red. As you can see the time is 9:19 am.
At this time I would expect the spots to be blue.

Lastly for the curious, the hub details screen shows the hub time matches the PC time and the Mode is Day

What if Sunset is earlier than 7pm?
Under location my sunset (South NJ, USA) shows 5:11 pm

Oops sorry - misunderstood. Not sure if times between carry on to the next day? Why not test for mode day?

If you change the order of the condition - make it (Time between Sunset and 7:00 PM EST) - does it change to false? (At 9:19am)

Is the lack of a trigger event due to the stripped down example or was it never set?

Some examples

Is Sunset before 7:00 PM? If so, then the rule is correct, and the result is what it should be.

If you have between two times of 5 PM and 4 PM, that will be true after 5 PM on day 1 until 4 PM the next day, and then false between 4 PM and 5 PM. That's a 23 hour period. This is what your rule is doing.

Don't you always need some kind of trigger?

You can just run the actions from the UI. I do this all the time to test actions.

1 Like

Oh I see. He's just testing

Yes, testing to show the "bug" with between two times -- except I'm pretty sure sunset is before 7:00 PM throughout the country right now.

Yes you are correct, Sunset is before 7pm.

:grimacing:

Actually, throughout the northern hemisphere!

2 Likes

OK for those who need to know. The rule is part of a motion sensor rule. More specifically when the motion becomes inactive and it's time to do something with the lights.
During the night and evening the lights turn off after a delay 1 minute.
During the Day whether the lights go off after a delay of 3 minutes or dim depends on the illumination of the room.
Which right now is working great because Evening mode occurs before 7 pm. However thinking ahead, come summer I will need to have a variation.
Even though is will be somewhat bright after 7 pm, I want to remove the illumination part (which will turn the lights on) and just turn off the lights.

Maybe I'm just missing the warm weather and over thinking it.
Why would I want such a rule? Well those particular lights reflect in the TV, wouldn't want to screw up prime time! First world problems of a retired person.

You need a more complex test, to know that sunset is after 7 PM. You could use a Boolean variable ("afterSunset7"), and set it at Sunset to true if it is after 7:00 PM (e.g. between 7 pm and midnight), and false otherwise. Then your test could be

IF (afterSunset7 = true AND Time between 7:00 PM and Sunset) THEN

Great, thanks.
The Sunset/Sunrise boolean has come and gone a few times in my code. I see what you are doing. Thanks for the swift response. This support community is great.

By the way, I also faced this issue, and the way I dealt with it, is by setting a global variable each night to the time of sunset. That way, I'm always able to do a comparison between that global variable and 7pm.

It turns out that these spot lights have my most complicated requirements while also being the most triggered event I have. There got to be a lot of conditional code executing each time there was activity at the sensor.
I also now realize that using the stripped down code in my original post really didn't help convey what I wanted. However the advice I got helped me understand what I really wanted.
Time for a rethink and a different approach, I wanted to move conditional logic out of the motion rule. I realized the problem became use 'illumanace' to control spots during the mode Day except if it is still Day at 7 pm otherwise just turn off the lights.

I was able to get it all working using a more RM triggers/rules while also simplifying each of the rules. A side effect of this was the global variable got factored out. It was a fun challenge with the result being a more event driven system.

1 Like

I still don't get it.
I have between 1201AM & 600AM set as conditions, it's 218PM, rule shows false and alarm still goes off. Then I had to deal with a rake to the head, from my wife who got scared sh!tless

Manage or Create Conditions is just a holding place for your conditions. You must include them in your Actions for them to do anything. Add an IF-THEN or a simple condition to your rule then select one of your defined conditions.

3 Likes