Thanks - so, the only thing you previous message confused me on slightly was using the same virtual switch for both ‘disable-on’ and ‘disable-off’. If Motion lighting subscribes to the ‘on’ state for both of those conditions, I think what I’ve built will work fine.
Why not just write a Bathroom App? I’ve seen you mention this use-case multiple times now. It seems to be a fairly specialized use case for a bathroom. You could write an App that handles this and then share it with the community.
First rule is the motion rule. It's going to turn on the light whenever motion is detected (your #1 above), and then turn it off 2 minutes after motion stops (your #5 above). Notice that it can be disabled by its own Private Boolean
Complexity comes in the second triggered rule for the door. If the motion becomes active and the door is closed (your #3 above), then it turns on the fan and disables first rule. That means that even if motion stops, the light is going to stay on. Then when the door opens it starts a timer for when to turn off the fan (your #5 above), and re-enables motion turning off the light with its timer (your #4). For good measure, it runs the first rule to be sure that the light is going to turn off, even if motion had already stopped when the door is opened.
Notice that the triggered rule fires on either of two events: motion active or the door becoming open. If it fires from motion active but the door is open, then the rule part is false, the fan switch is scheduled to turn off (it is already off), the motion off is enabled (it is already enabled), and the rule is run (it already just ran). But, if it is triggered by the door opening, then it does those same actions as your use case calls for.
There's a certain type of logic that's used for home automation that is ... slightly tangental to traditional logic. You can learn it but it's not intuitive for many people.
As an example, "disable on" and "disable off" in home automation means disabled when on, enabled when off for the first, and the opposite for the latter... But traditional logic would assume that the first switch turns ON the disable, and the second switch turns OFF the disable.
I actually like @ogiewon’s suggestion of writing an app to do this. It’s not a very difficult app.
When RM first came into existence, it was common for me to write little apps like this one all of the time for people in the community. But so many people kept clamoring for a “rules engine”. So, over a weekend Rule Machine was created. It grew rapidly once released, as people had more and more requests for little features here and there. It is by no means an ideal tool, but it is a very flexible and adaptable tool that can be made to do many tricks. Personally, I don’t use it for very many complex automations such as the one you are looking at.
Later, I found that a dedicated app such as Motion Lighting filled a real niche. To do the more complex Motion Lighting applications requires multiple rules. I dislike the clutter of multiple rules to handle a single automation, such as this one. My efforts recently have been to distill generalizations of things like motion activated lighting into a general purpose app, such as Motion Lighting. I have 30 instances of Motion Lighting in my system, and 56 rules. I used to have something like 120 rules.
In my system overall, I only use 7 apps. But 4 of those have about 100 child apps (Button Controllers, Lutron Integrations, Motion Lighting and Rule Machine). The 3 others are Amazon Echo App, Life360 Connector, and Mode Manager.
We will continue to add a few apps that are generalized and can help people easily set up their automations with efficiency. We are open to suggestions along these lines.
Thats precisely the difficulty I have when setting up my automations. I have to turn my thinking on its side to get through anything other than the simple setups.
I agree. These were always arbitrary choices that were made, and not all of them are consistent in the sense you mean. There is a presumption -- actually a not very good one -- that people will actually think through these things somewhat carefully. Simple is better, almost always. But, there are instances where automations are complex by nature. There is a balancing act when writing these apps between keeping things simple, and providing a covering set of capabilities.
in motion lighting i have set that up to be the switchonenabled and switchoffenabled
when that switch is turned on only switchonenabled is effected.
what i am attempting to accomplish:
person has entered room, tripped motion. lights on. perhaps through dimmer or alexa overridden dim level (perhaps not), now wants to leave the light setting at current. no turn off, no motion re-setting to the preprogrammed dim level by mode. That virtual switch might be changed by: physical switch, alexa, phone (someday), dashboard / tablet (someday) or a pico.
My suggestion: If you’re trying to do anything more complicated than “sense motion, turn on light. Motion stops, wait x minutes, turn off light” then you’re probably better off using Rule Engine. Yes, there are other options but that’s really the focus of the app.
Delayed On works but will work regardless if door is opened before the wait period. The fan will still come on.
Pending On works only if motions “Stays” active during the wait period. Seems like the timer resets every-time motion goes inactive and then back to active. The result is the fan does not come on as desired.
Unfortunately, I have no idea how to even begin writing an App but I am willing to try!
You did help me get the rules down to 4 now plus a Virtual Switch.
Motion Lighting doesn’t seem to play nice with my GE Switches…