Trigger When a Mode Switches Off

Hubitat!

It is easy to trigger on a mode change into a mode. However what about triggering when changing out of a mode. For example, I have a Cleaning Mode I use for when cleaning house. I have a series of different ways through buttons and virtual buttons to activate that mode. Once there, many other rules are paused to prevent various triggers from interrupting Cleaning. I do not believe it is efficient nor good programming to have to attach "resume" actions to every rule in my system. What I have right now is an action that is called by the "Cleaning Start" rule which pauses the important actions then a reciprocal action which resumes all those that are paused. That action has to be called by just about every other automation in the system. What would be better is a trigger that calls the resume action whenever the mode changes from Cleaning to just about anything else.

I'm trying to decide the most efficient and tidy way to achieve this and I am hoping the community has a known solution before reinventing the wheel. This seems like one of those trivial onesā€¦

Thanks,
Richard

Can't you use a condition/rule for Mode is Cleaning, then put your actions under False?

@destructure00 I considered that. Wouldn't that fire every time the mode is not Cleaning on any and every mode change? What I specifically need to catch is any time the mode changes from Cleaning to something else. It is the "off-ing" of Cleaning.

One way I am considering rearchitecting this (and that I know will work with certain other advantages) is to implement "Cleaning" as a switch. I could create a Virtual Switch for the task then attach actions to it. I still would prefer to work within the modes framework so I am hopeful there is some other solution.

Another question for the community ā€” how and when do Rule Machine conditions and triggers evaluate and then act? I never have seen a timing chart nor diagram explaining this. It would be a helpful addition to the documentation too.

ā€“ Richard

With the mode/false thing, actions only run when the rule truth changes, so they would only run when it goes from True to False, which means they would only run when mode changes from Cleaning to something else. If mode changes from non-cleaning1 to non-cleaning2, the rule does not flip states, so no actions are executed.

1 Like

I to wish there was a ā€œchanges fromā€ type condition in RM.

I solved this exact scenario with a virtual switch. When my cleaning lady arrives and puts her code into my lock, the virtual switch turns on and when she leaves the switch turns off.

I have a rule in place that runs actions when the switch turns on such as change the mode to cleaning and the house brightens, fans turn on, etc. Then when she leaves the switch turns off and the same rule truth changes to false and I have different actions execute to change mode back to Day but turn off specific switches that were turned on during cleaning.

1 Like

Thanks to both of you ā€” @destructure00 and @ritchierich for the thoughts. I know @ritchierich's concept will work as I have other mechanisms in my system (i.e.ā€” a "Napping" switch for bedrooms) that echo this architecture. But I do see cleaning as a location-wide modal event. Off we go back into the Rule Machine works!

Thanks!

2 Likes

I am thrilled to report that I've implemented this exactly as @destructure00 recommended. It's 100% working. To whom or where can I suggest that the Rule Machine documentation is updated with this exact example? I also very much would like to see Rule Machine's "evaluation and execution timeline" diagrammed.

Thanks so much!

2 Likes

Please place your documentation in this Area.

@destructure00 has taken the time to create an interesting format for documenting examples, feel free to imitate. :slight_smile:

Personally, when I added an example, I imitated this one:

1 Like