Little help figuring out what happened with these rules last night?

I have an upstairs bathroom light (bulb) and a motion sensor in that bathroom. I have 3 main modes I use when I'm home. Day/Evening and Night. Night is sleep time.

During the Day/Evening I have a Motion Lighting rule that looks like this:
image

So that handles Day/Evening movement in that bathroom.

At night I have a "Night Lights" routine that turns a lot of lights on low when motion in sensed in the house during sleep mode. Generally so I can wake up in the middle of the night and tend to my daughter if she wakes up. I have two rules for this. One for on and one for off, they are:

and for off:

No restrictions for any of these rules. Last night my daughter gets up at 1:30ish in the morning. I get up and the Night lights turn ON. As I walk up the stairs I see the bathroom light on (it's in the on rule). My daughter has to go to the bathroom so I take her in there. Within a minute of being in there the light turns off. Logs from the light and the motion sensor.

First the light. I included the events prior to what happened also:


So you can see light on and light off.

Here is the motion sensor events:

Here is the first motion sensor that would have tripped the "night lights" routine to being with. Just for timing sake:

So if the motion lighting rule turned it off for some reason...8 minutes had not even come close to passing at this point. I would have walked by a few of the motion sensors in the LIGHTS ON rule on my way there. Including triggering the one in the bathroom which is part of that rule too. So 1:31:00 the first motion sensor tripped. By 1:31:46 (46 seconds) I was tripping the upstairs bathroom motion sensor. Light turns off at 1:33:02 so 2 minutes after the first trip. Which would make sense...unless I'm not understanding rule truths? I would have thought the LIGHTS OFF routine with the delay by 2 minutes with cancel would have at least been reset by the upstairs bathroom motion 46 seconds later?

What am I missing. What turned the light off?

1 Like

Just a wee bit of complexity here! That makes it harder to sort out, for sure. Getting logs from the rules would help figure this out. Look at the App Events from the app status page.

The motion lighting app has nothing to do with it, since it only deals with Day and Evening.

This is too dense to sort without all of the logs. Allow me to suggest that you should simplify this, and take the double negative of a rule-truth being false out of the equation. Why can't you put all of this into a Motion Lighting rule for Night, instead of two rules? Or, even into one rule?

I'm all ears...but really there are just 2 rules turning on and off lights. If I make 1 rule when false turns off lights...then it turns off lights in other modes because mode isn't "night" so that makes the rule false..the false turns off the light. Hence two rules. 1 that senses motion and mode is night. The 2nd rule..sense rule truth of the ON rule and mode is night...then turn off with delay and cancel. doesn't seem complicated? Just 2 conditions for 2 rules? If there is a better way....I'm all ears.

That LIGHTS ON rule doesn't got false until 1:36. That light was turned off at 1:33:02

FYI, the rules this light is associated with:

Google Home is...google home
The two rules above LTS
and the Motion Lighting rule

VIRT-LIGHTS is just a rule that monitors all the lights in the house and goes TRUE when they are all off. It's just an indicator for me.

Use a mode restriction, or just use Motion Lighting.

Been here. The problem I've had with "restrictions" is that if that mode changes while in the middle of the rule the rest of the rule doesn't get processed. I learned that early on from you when I was using time restrictions vs conditions. lights would come on and never go off because the time passed while the light was on. Mode switches at 6am (mostly) every day. There are times where someone is up before that...so that happens a lot. Also there are lights in just about every room of the house on this "night lights" list. So I can't just do one motion lighting rule...and some of these lights are in rules that just keep them on with it being dark outside (not motion related).

But...back to the original question. What happened? The rules really aren't that complicated(two RM rules). The situation seems fairly straightforward. The logging shows the light going off...but the logic logging does not.

I don't know what happened. The LTS-NIGHT LIGHTS ON rule doesn't turn the lights off. What are the logs for the rule that you think turned them off?

OK. That's why I would use Motion Lighting.

Sorry, forgot to add this one...and it's important! This is from the OFF rule

That's interesting. At first blush. it's as if it went true when the other rule went true. I'll dig into that one a bit. That would explain the lights turning off when they did. The lights turned off 2 minutes later.

Obviously, if that's the case, that's a bug. It should go true when the other rule goes false.

OK, I found the issue. There was a race condition happening that bit this particular combination. We saw this a few days ago in another context, where rapid events were evaluating wrong due to a race condition. It's the same problem. It's been fixed, and will be in the next release coming out this week.

I was able to replicate your failure with the in-service version of RM. Then using the dev version (next release), it works as expected.

4 Likes

Thanks...I will also look into moving the rule in ML. However having the Rule Truths available I have found handy for other automations. Thanks for looking into this!