Multi light rule help

So I am trying to develop a rule that covers off multiple conditions. So far I have the below.

To explain the complete scenarios I am trying to fulfil:

I want the main lights to come on whenever we enter the room between 5:30 am and sunrise or when the mode is evening or night and then go off if motion becomes inactive after 5 minutes which will cancel and reset if motion is triggered again....Unless the TV is turned on then the main lights must stay on..

What I am struggling with is:

  • How to turn the lamps on and have the main lights turn off and visa versa

  • how to turn lamps and lights off while TV is on and have them stay off

  • The Cancel rule doesn't really seem to work, I can wave my arms around and the lights will still go off after(I did change it down to 5 seconds for this test)

where am I going wrong?

I already created something similar. This is how i'd do it. There is more than one way to frost a cake, but I like to keep things simple. I might have gotten the names wrong in your rule, but the syntax will work. I have the same rule running in my home. But way more complicated. Hope it helps you. If you post your revised rule with triggers, I'll see if I can help more.

triggers:
Lounge motion sensor changes
lounge lamps change
lounge tv changes

If
lounge sensor is active
and
lounge lights are off
and
time is between 530 and sunrise +30
and
lounge lights are not on
then
on lounge lights
cancel delayed actions

else if
lounge tv is off
and
lounge main lights are off
and motion is inactive

then
turn off lamps - delay 5 minutes - cancelable
end if

This could definitely be done with Rule Machine (and something like the above may work--I didn't read the whole rule), but is there any other reason you're trying to use Rule Machine? The built-in Motion Lighting app can handle most of this with a lot less effort. (You may be thinking, "But what about the TV?" The answer is the "Switch to disable off" option in Motion Lighting--there are a lot of customizations like this you can make.) One reason your rule doesn't work is that the "Cancel Delayed Actions" action only works on actions marked "cancelable," and you have none (you probably want it on the delayed action), but I think there are other logical (truth/IF THEN) errors in your rule too.

I'm not sure about the main vs. lounge lights. Do you just want one on when the other is off? I don't see the main lights getting turned on anywhere in your rule, so I'm guessing you have something else to handle that (?). Simple Lighting might be able to help, but so could RM. Just trying to think of ways you might be able to make this easier.

+1 for setting this up in Motion Lighting. It would probably be a lot simpler to get working.

Part of the problem with your rules is that you have both ORs and ANDs in your IF statements, but you don't have any parenthesis to show how you want those to be evaluated. Logic needs to be really specific or your results may not be as expected.

I'm also wondering why you have "NOT Lounge Lamps is on". Why not just say "Lounge Lamps is off" ? That would be more straight forward (albeit awkward English).

Cancel isn't working because you don't have any delayed actions that are cancelable. You have to specifically include that in the action.

Are you turning the lamps on manually? Do you want the lights and lamps to turn off automatically when the TV comes on? Or do you want to manually turn them off and have them stay off?

1 Like

I'm not sure how RM will process as your conditionals currently sit, but I would recommend putting parenthesis around your OR conditions. So place them before the time and after the mode conditions in the first and then before the lights and after the lamps on the second.

So... IF ((Time between 5:30 AM GMT and Sunrise+30 minutes(F) OR Mode in Evening, Night(F)) AND ...

I'd assume that if the lights are on, they'll turn off after 5 seconds. But if the lamps are on and lights are off it'll work like you are hoping. This really only applies to the cancel issue.

Thanks for the responses so far to answer them all in one post instead of multiple here goes:

@april.brandt - That helps, but I can't see it factoring in lamps going off in lights are on and visa versa

@bertabcd1234 and @jabecker I had some of the rule working in motion lighting, but as of late i've had problems with motion lighting with lights not triggering on or off despite plenty ot repeaters and i've not been able to get an answer as to why in support. I've had to remove all my apps and start again which seems to have fixed it for now. I also used NOT on as I wondered if it was "off" that was causing issues but didn't make a difference. From all of the comments it looks like my rule needs re-writing to be more logical

@Boredom thanks for the pointers i'll see what that does

I think I nailed it

Lounge Lights on - If TV is on or motion is active and Lamps are off
Lamps on - if TV is on or motion is active and lounge lights are off

So It seems as if I have to control the lamps on and off and it will take care of the lounge lights..Let me know @april.brandt @bertabcd1234 @jabecker @Boredom if there are conflicts you can see

Glad you got it working.

Glad you got it working.

My only suggestion — and this is a purely personal preference — is to limit complex structures by splitting things up or combining where possible. Something like:

IF ((Time between 5:30 AM and Sunrise +30 minutes OR
      Mode in Evening, Night
) AND
 ( Lounge Motion Sensor active OR
   Lounge TV is on )) THEN
    IF Lounge Lamp is off THEN
        On: Lounge Lights
        Cancel Delayed Actions
    ELSE
        Off: Lounge Lights
        Cancel Delayed Actions
    END-IF
END-IF
IF (( Lounge Lights is on OR
        Lounge Lamps is on
) AND
Lounge Motion Sensor inactive AND
Lounge TV is off ) THEN
    Off: Lounge Lights, Lounge Lamps -> delayed: 0:10:00 (cancelable)
END-IF

As I said, this is purely subjective. I just hate to have to type in stuff more than once. :wink:

Wow that streamlined half of my rule :joy:

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