Balancing Rule Machine / Modes with Motion Lighting

Wondering if one app takes priority over the other, or rather how not to create a conflict.

I has set up some lighting rules by mode using Rule Machine for the dimmer in my hallway. But I want to add a motion rule on top of it for one of the modes.

My modes are Morning, Day, Evening, KidSleep, and Sleeping.

Morning Mode: Turn on the hallway light 5% on motion. Keep light on until Day Mode.
Day Mode: Off
Evening Mode: Turn on 15%,
Kids Sleep: Dimmer to 1%.
Sleeping: Off. Turn on 1% with motion. Turn off after 1 min.

I suspect I have a conflict in the Sleeping mode between Mode Lighting turning it Off and Motion Lighting turning it on. The light is not turning off when mode changes to Day.

Am I better off managing the lights in Rule Machine rather than using Motion Lighting for the motion part? Time to ween myself off of that crutch, I guess.

Do you have a trigger on mode change? Can't see that, so maybe by adding that, it would turn off when mode becomes day.

Not seeing that as an option. Where should I be looking?

In my head, this should be easy. The conditions should be either "just mode" or "mode AND motion" but I'm pretty new to using rule machine rather than the built in apps.

When I add a second trigger, it shows up as "Or" and I'm not seeing where to make it "And." I think I need to explore the Action part rather than the conditions.

To have it turn off when the mode change, after it has been turned on by motion, you add it as a trigger. In the top one. The OR is correct. Try and see. Change the modes manually to test if that works for you.

This is something I've knocked up very quickly in RM4 to give you an idea of what you might be trying to achieve.
Obviously I do not have all your modes but it gives you an idea of how to build it.
Every time the mode changes or motion changes (triggers) the rule will be evaluated.
Like I say, very raw, but it should give you an idea.



Got it.

Yeah, the modes have been changing appropriately when I had it set up just as a Mode Lighting rule.

Figured I was going to need a few "Else If"
Set up the "change" as the condition for both, then define the changes in the If-Then-Else. Will give that a shot.


1 Like

In the last ELSE-IF, the 'OFF' for the dimmer has been set to cancelable.
Above it you can see 'Cancel delayed Actions'.
This will mean if motion is detected again before the light turns off (1 minute delay), the delay will cancel effectively keeping the lights on and starting the 1 min timer again when motion inactive.
You have probably realised this but thought I would mention in case you were wondering.
Good luck!!!!


Thanks for the great example.

I never understood how to use "changed" in a rule. I didn't realize you could later define its status. I thought it literally just meant "toggled." Also hadn't realized that you were just defining which triggers you'd be using in the rule rather than setting the specific trigger. I need to play with Rule Machine more to get more comfortable.

If I'm following right, here's what I get.

Looks like it should work.
Do you have any other modes? Maybe away or something similar.
I'm just wondering if the light is on and mode changes to away then there will be no trigger to turn it off, or change it to whatever state you want.
Just a thought.

1 Like

That's it for modes. I don't use away.

Fingers crossed. :crossed_fingers:

1 Like

DAMNIT @bobbles! You didn't tell me I forgot to turn off the light at Sleeping Mode! What kind of support forum is this?!?!?!


Rules worked great (other than my omission of turning off the light when Sleeping mode starts). Thank you so much for your help. That was the first time I set up a rule with multiple conditions for multiple modes. I feel EMPOWERED! What can I f&*k with next? (working from home today) <>maniacal laugh</>


Ha Ha. Glad it worked for you. (Apart from my omission of course). :wink:
I would suggest if you're like me there will always be something you forgot to consider when writing more complex rules. I nearly always do.
Just a suggestion, (again in case you don't know), you can clone rules.
So if you have a really complex rule that you want to tweak, clone it and then pause it. Now do your tweaks on the cloned rule to see if it works. If it does, great. Just delete the original paused rule. If it screws things, just delete the cloned rule and do a new clone and try again.
Just another bit of info for you.
Happy automating.....................


Great advice on cloning. This would have saved me a few headaches! :slight_smile:

1 Like

last question. not sure if I'm getting the conditions right for what I want in sleeping mode.
I left out the "turn off" when changing to sleeping mode. But what I want is "turn off during sleeping mode, and turn on for 1 minute if there's motion in the hallway."

Do I need to set the condition for "If its sleeping mode and NOT motion" as well? I'm not sure if I'd be creating a conflict if I put it in or if I left it out.

Maybe change this


ELSE-IF (Mode is Sleeping
       IF Motion active THEN
       Dim: Upstairs Dimmer: 1
       Cancel delayed actions
       ELSE-IF Motion inactive THEN
       Off: Upstairs Dimmer --> delayed 0:01:00 (cancelable)
ELSE-IF .......

Then delete the last ELSE-IF.
That would be a better way of doing doing it I think. (Nested IF's).

Thats what I was trying to do, but I suck at getting the nesting structure set up. Really would like a drag and drop UI for this stuff (like my 4 year old daughter's Frozen coding game).

Did you get it done OK?

working on it now.
I struggle with when to tell it do to a sub-expression.

ELSE-IF (Mode is Sleeping

When you have put this statement in,
Click done
then select conditional actions again. The select IF - THEN again.