Race Condition with Mode Change?

This is probably a misunderstanding on my part, but I'm seeing a rule fire twice when I think it shouldn't. Here's the scenario:

  1. Mode changes happen at a specific time and can also be acutated with a switch
  2. Rule that triggers on Mode change has restriction that Mode must be the previous one (must be in Night Mode to run Morning Mode rule, for example)
  3. First Action in the Rule turns on the actuator (in case the rule triggered b/c Mode changed at designated time)
  4. Last Action in the Rule is a Notification of the new Mode.

What I'm seeing is that when the Rule is triggered before the expected time by the switch being turned on (e.g., "Alexa, turn on Morning Mode"), the rule fires twice and I end up with two identical Notifications. What I expected was that, since the Mode change has already occured (that's what triggered the rule, after all) and there's a mode-based restriction, turning on the actuator within the rule would not cause the mode to "change" again. Apparently it does, though, since I'm getting two notifications. They happen at the "same" time; milliseconds apart, of course, but the time stamp in Notifications is the same.

I assume this is fixable with a short delay, but this feels like a bug to me. Am I missing something?

1 Like

Can you post a screenshot of the rule?

Of course. Here you go. "Evening Mode" (and other similarly named) is a virtual switch that can be used to trigger evening mode via Mode Manager. It just triggered a little while ago and I got two Notifications, as before. Second screenshot shows the log entries.

You've showed logs for 3 apps. Only see a single entry in those logs for RM. Most of those are clearly from Room Lights. So it's not really possible to tell what is going on from what you've showed.

Seems like you've probably got too many cooks in the kitchen when it comes to modes. Probably need a rethink along the lines of Keeping it Simple Stupid.

Right...there's nothing in those logs for the RM instance you shared. You've definitely got a lot of repeat stuff happening.

I'm not sure what your exact use-cases are, but, for the virtual switches for the modes, why not just set the switches to auto-off after 500 ms? That would allow them to stay on long enough for mode manager to pick it up and turn them back off. That would help to simplify that RM (and presumably others) and would reduce the chances of repeat triggers.

Alright, let's try again. Screenshots show the Day Mode rule, Mode Mgr log, and Day Mode rule log from this morning. It appears to trigger twice due to two events. Not sure why there are two events.

Show the Event Subscriptions for the Rule. What is "Aptos Hubitat"? That's the second trigger, but where is that coming from?

Also, look at Location Events on a Logs page.

Aptos Hubitat is what I named my hub (on the Details page). Screenshots of the Event Subscription and Location Events Log below.

Looks like it might be a bug, will investigate.

Are you running If not, please update and try this again. Show the logs for what happens on transition from Morning to Day. My initial tests (on do not show a problem.

OK, I was on and have updated to .140. I'll check on it tomorrow morning and see what happened.

There is a bug in this situation where there is mode both in Required Expression and Trigger. This will be fixed in the next release, but that is not likely to be soon.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.