RM Example: Turning Lights ON & Off. Different days, Times & Motion. Complex Rules

In webCoRE I had one piston that would control lights by turning them on depending on the time, Lux level and also motion. I would then turn them off using the same options. Once I got my head round webCoRE it was relatively easy yo do.
I want to get everything on native HE apps and this took me 4 rules to do it.
I thought I would bite the bullet and try to do this using complex rules and try and get it into one rule.
Although this is not as user friendly to do in RM as it is in webCoRE, I have come up with this.
Just thought I would share it so people can see a use case for complex rules.

6 Likes

I think this is missing the part where the lights turn on. Or am I not seeing it?

All I have shown is how to set up a complex rule with 4 different scenarios that if any are true, in this instance, enables you to do what you want. All elements have to be false in this rule for it to evaluate as false.
Here is the complete rule for reference.
I've shrunk it down to show it all but I'm happy to post a couple of screenshots if that helps.

It’s a shame on the Select Actions For False statement you can’t specify a device - for example, when the motion sensor stops detecting motion, then continue the false statement (turn lights off). @bobbles what happens if there is further motion with this rule at the moment? Is the counter reset for another 15 minutes? Or does the light go off at the end of the 15 minute window from first evaluation?

If motion is detected in the 15 minute window then the timer stops and will restart from 15 minutes again when motion becomes inactive.
If you look at the screenshot you will see a 'Stop Actions'.
PS. You can select the light if you wish. I just like random turn off times between, say 15 and 45 minutes. This way if we are away it doesn't look like the light turns off at the same time every night.

1 Like

So for Stop Actions it gives me a list of different rules (This Rule and all other rules ive created so far) - is that the one you mean? Sorry, Ive only started out on Rule Machine today, still getting my head round it after using WebCoRE for a long time lol

Correct. I'm sure you will get there.

1 Like

Thanks.
So does your rule for “Dining Room Socket-Turn Off” just literally turn off that socket or does that one have some logic in it too?

Yes. All it does is turn the lights off after a random wait.
Unfortunately with RM you cannot specify an action to turn off a light between random times of say 15 and 35 minutes.
You can put in 35, select random and it will turn off at a random time between 0 and 35 minutes. When I first did this occasionally the light would turn off after 1 minute and we were still in the room but hadn't moved much so the rule became false and turned the light off.
I want between 15 and 35 minutes.
By having another rule to turn it off after a random time, as seen below, I have got what I want.
First rules waits 15 minutes before moving to the next rule which has a random delay of 20 minutes. Hence I get a random my delay of 15 to 35 minutes.

Hope that all makes sense. :slight_smile:

image

1 Like

Hehe that makes perfect sense. Great thinking outside the box for that rule :+1:

I don't see this. Is it the Delay by 15 Minutes Cancel?

image

This is mainly for when the rule becomes false. After 15 minutes the second rule - "Dining Room Socket Turn Off. Random Delay" becomes active.
If the rule becomes true again before the delay rule matures, the Stop Actions will stop it from maturing and turning the light off.

Could you also use the Delay Action and slect the Cancel on Change of Truth?

Yes. That is what I have done.

@bobbles I was wondering, when your lights go off, and there’s motion immediately after, what happens for you? I’ve done 2 similar rules based on your hard work (without using random delay periods to switch off), however when the light has gone off if there’s motion again straight away the lights don’t come back on:

Any suggestions? Can it all be merged into one rule? And would that overcome the light coming on issue?

I haven't seen that issue I'm afraid.
In your case why have the second rule.
In the first rule for false just use wait 30 seconds (cancel on Truth change) turn off.

1 Like

Oops. Lol damn obvious when I think about the off part for my situation :grimacing: I wonder if that might be why it’s olaying up for me on lights off due to calling another rule. Thank you

1 Like