Predicate that traverses midnight not working

I have a rule that turns my porch light on at sunset then turns it off at 11PM.

Between 11PM and Sunrise, I want the light to turn on whenever there is motion - and turn off 5 minutes after motion is inactive.

This is my rule. I expect the light to never turn on after sunrise, but it's turning on whenever there is motion all day long.

What build are you on? A recent hotfix fixed something related to either sunrise or sunset (maybe both?) in predicates, so I'd try updating if you haven't already.

1 Like

In addition to answering the question above, could you also look at the App Status page, in the Application State section, and show what the value is for "stPrimed".

Build 2.2.8.141. Updated yesterday.
I got home today to discover that my front porch was on. I just updated the above rule to start at 11:01PM instead of 11:00PM in case there was some race condition. It looks like saving that rule shut off my front porch light

stPrimed is currently false, and the light is currently not turning on with motion (correct behavior).

I will report again tomorrow, but as you can see from today's logs, the front porch light was turned on/off a lot (and there is no other rule or switch that controls it other than "turn on at sunset, turn off at 11:00PM)

dev:142021-07-25 10:37:54.541 am infoFront Porch was turned off

dev:142021-07-25 10:37:35.454 am infoFront Porch was turned on
dev:142021-07-25 10:36:19.554 am infoFront Porch was turned off
dev:142021-07-25 10:32:22.336 am infoFront Porch was turned on
dev:142021-07-25 10:31:25.774 am infoFront Porch was turned off
dev:142021-07-25 10:30:46.422 am infoFront Porch was turned on
dev:142021-07-25 10:28:41.287 am infoFront Porch was turned off
dev:142021-07-25 10:23:10.851 am infoFront Porch was turned on
dev:142021-07-25 10:08:07.289 am infoFront Porch was turned off
dev:142021-07-25 10:02:35.740 am infoFront Porch was turned on
dev:142021-07-25 09:54:05.890 am infoFront Porch was turned off
dev:142021-07-25 09:48:35.422 am infoFront Porch was turned on
dev:142021-07-25 09:40:58.413 am infoFront Porch was turned off
dev:142021-07-25 09:35:10.106 am infoFront Porch was turned on
dev:142021-07-25 09:30:59.920 am infoFront Porch was turned off
dev:142021-07-25 09:25:12.008 am infoFront Porch was turned on
dev:142021-07-25 09:21:46.615 am infoFront Porch was turned off
dev:142021-07-25 09:15:55.922 am infoFront Porch was turned on
dev:142021-07-25 07:33:24.924 am infoFront Porch was turned off
dev:142021-07-25 07:27:52.236 am infoFront Porch was turned on
dev:142021-07-25 07:20:04.393 am infoFront Porch was turned off
dev:142021-07-25 07:14:29.678 am infoFront Porch was turned on

Could you show two more things from that page (use screenshot): At the bottom, Scheduled Jobs. In the middle, Event Subscriptions.

When I changed the rule from 11:00PM to 11:01, I accidentally chose 11:01AM, which explains the "Prev Run Time"... but the rule is currently set for 11:01PM, so "Next run time" is incorrect it looks like...

Here is the rule right now...

All of that looks correct. So, let's see what happens...

Looks like the rule is still firing... went outside and saw the light on...

Name Value Unit Description Text Source Type Date
switch on Front Porch was turned on DEVICE 2021-07-25 12:15:10.638 PM PDT
switch off Front Porch was turned off DEVICE 2021-07-25 12:08:58.496 PM PDT
switch on Front Porch was turned on DEVICE 2021-07-25 12:03:20.679 PM PDT

I turned on debug logging for this device, we'll see if that gives me any more info...

Please turn on Event, Trigger and Action logging for the rule. You don't really know that this is the rule turning on the lights, just that they are turning on. Use screenshots for logs please. Look at the Front Porch device page, at the bottom, where it says In Use By, and take a screenshot of that.

Where do I turn on those logs?

Here you can see the Front Porch & Uplights Off/On rules

Alexa has "hunches", where she watches for patterns and fulfills them for you. That might be the source of this. Check the Alexa App. But, the logs for the motion rule are critical to see.

On the rule page:

1 Like

There are no hunches set up... will let you know what the logs say next time.

1 Like

Well... since I re-saved the rules, this hasn't recurred... so ... fixed! :slight_smile:

I'd like to mention that I moved all of my rules (there weren't many of them) over to RE 5.0.

One of my rules had a predicate that was (Sunset-30min to Sunrise+30min).

That rule was incorrectly firing during the day, and it was the only rule (with a predicate) that DIDN'T say (Predicate False) after it. So presumably it incorrectly thought it was true.

I went in and edited the predicate, but didn't make any changes. I also turned on logging. When I re-saved it, it now shows predicate false.

So - I still think there is a bug somewhere- that perhaps only occurs on initial rule creation, but fixes itself if you re-save?

Just FYI I did this exact same thing in the Motion and Lighting app, was pretty simple in there. Not sure if there is an advantage to using the predicate conditions?

Ok @bravenel I have another rule that is misbehaving - "Garage Lights On".

It's called 'Garage Lights On'.

The rule is simple:

You can see what it is in use by:

and here are the logs for that app:

You can see that the door opened at 9:34AM and the rule triggered, turning the lights on. 9:34AM was certainly not between Sunset-30 and Sunrise+30.

Event subscriptions:

stPrimed is true

No scheduled jobs:

This one is now turning the lights on every time the garage opens

I should mention that I did upgrade to 2.2.8.143 the day before yesterday.. so this is still happening with the latest version...

Heh, I now see 2.2.8.147 is out... let me download and install that.

1 Like

Now running .147, opened garage, lights (incorrectly) turned on.

1 Like

I have found the source of this problem. Fix in the works...