Motion sensor events not reliably triggering rule

Platform Version
2.4.3.172
Hardware Version
C-8 Pro

I have a rule that turns on lights when a motion sensor becomes active. Sometimes this works normally, but other times when the motion sensor becomes active no event is generated and therefore the rule does not trigger.

An example when it works:

An example when it does not work:

In both cases, there is an Info log entry:
Drive motion sensor motion became active

In the working case, this is followed by another Info log entry:
Event: Drive motion sensor motion active

However, in the non-working case this second Info log entry is not generated and the rule does not trigger.

I don't see any pattern as to when the triggering works. It seems to be random. I have other rules that are working 100% of the time.

Welcome to the community!

Can you post a screenshot of the full rule itself?

Sure:

I have verified that the missing "Event" log entry is not related to "mode is night". For example,

I've had some "dangling" things happen is required expressions and other places. Disable this rule and reenter from scratch as a new rule and see if that clears things up.

The rule shown above is "app: 69", correct? What rule is "app: 70"?

In the Logs screenshot in your last post there, the entry at the top shows app: 70 logging the motion disable as an Event -- does that app:70 rule have any connections to the app:69 rule?

I'm just trying to determine if something else is somehow disabling (for lack of a better term) app:69...

That's correct, the rule above is app:69. app:70 turns the lights off 3 minutes after the motion sensor goes inactive:

Nuts, I'm at a loss... I keep my rules less complex in terms of variables and dependencies, so I'm admittedly not the best person to help reason through what you have going on here with these two rules.

What is the "Outdoor lights trigger watchdog" that gets set to True in the "Outdoor lighting on" rule (app 69)?

This almost certainly doesn't have anything to do with that rule misbehaving, but it's good practice to always be in the habit of closing every IF with an END-IF... When there's just one IF (like that rule), it shouldn't matter, but missing END-IFs will definitely cause chaos in other circumstances.

The example where it doesn't work was at almost 10:00 AM. Was your mode still Night?

1 Like

That log entry is coming from the rule when it has an event subscription on the motion sensor for the trigger. In the case where the rule doesn't log it, that is because it isn't subscribed to the motion sensor. The most likely reason being:

as you have this condition in your required expression. When the required expression is false, the trigger event subscriptions are removed, which would explain the event not being logged. You should see "Required expression now false" somewhere in the logs prior.

Please see my response to hydro311 above:
"I have verified that the missing "Event" log entry is not related to "mode is night". For example,"

Mode changes to Night at 6.08pm. Then the problem happens at 8:12pm.

I had some cases where the hub would get the active command from the motion sensor but the inactive command would be missed. So, then the lights would stay on (possibly all night). So I added a "watchdog" to shut off the lights if the inactive event never comes.

Strange thing is that everything seemed to be working (including the watchdog) for a couple months. Then recently I noticed that I would come home in the dark and the lights wouldn't turn on. I assumed that the problem was the motion sensor. But when I looked at the logs I found that the motion sensor is sending active commands but the rule is not using them. I haven't modified the rule at all for quite a while.

I'll try adding the end-if to see if that makes a difference. Thanks.

1 Like

Any chance that "mode night" could have happened when the hub was down somehow?

I'm not sure when or how that gets set in your case.

There is a log event "Hubby mode Night", so that seems to indicate that the mode actually changed to Night. Night mode is set at sunset.

While there may be no reason you know of why mode is not still night at 8:12pm, you still should not just assume something when troubleshooting. Did you physically check that mode was still set to Night after it didn't fire at 8:12pm?

I'm not assuming the mode was Night. The log says the mode changed to Night at 6:08pm:
Event: Hubby mode Night

Are you saying that the logs cannot be trusted? If the logs are not accurate then I don't know how to debug this.

I'm not saying logs can't be trusted, if anything I am saying maybe you can't trust mode is staying Night. Something else could have changed it again after the log that said it changed.

Maybe add a rule that will log whenever mode changes, to be sure nothing else changed it, or, I was just saying you should check it manually if you can catch an instance of the rule not working.

Are you logging Events, Triggers, and Actions for the “Outdoor lighting on” rule? I don’t see anything in you logs.

Yes, all of those are being logged for "Outdoor lighting on". If you look at the first log I posted (working case) you will see a log entry for all three.

Ok, I missed that.
The only times I’ve missed a trigger are:

  1. Required expression is False
    Or
  2. I was editing the rule and didn’t “update rule” or “done” before leaving the rule page. The subscription was not enabled.

I would “triple check” both.

Also adding a “test rule” that has the same RE and trigger but just logs that “It Fired” might give some insight.

2 Likes

I might even go one step further and create another rule with no Required expression but with the a conditional trigger. Then look at all 3 (original new with and new without RE). As others have mentioned I have seen RE's act very odd all of a sudden.