Rule for manual on and off when motion stops

Hi guys
I need a rule where i turn on/off a light with a push of a button and at the same time check if there is motion in the room. If there is no motion/presents in the room the light would turn off after some time. I really appreciate you help.

Just so me and others understand, why would you want to use the button and motion if you ultimately are using motion as the "test" anyway? Wouldn't it be sufficient to just use motion, and override (block turning off) with the button?

Hi
@neonturbo got a point.. And what should happen if there IS motion when you press the button?
Now i'm not 100% certain that i understand your use case, but you would need something like:

Trigger "Button pressed"

IF Light are off AND Motion sensor is inactive
Then
TURN ON Lights
Wait for XX time
TURN OFF Lights
ELSE-IF
Lights are on
Then
Turn off lights
END-IF

If you also need the lights controlled by motion, the rule would need some additional lines.. :slight_smile:

it would be a simple off with a motion/presence checking because the children always leave the light on :slight_smile:

The simplest way to do your simple off thing is to have 2 simple rules. One rule for the button, if pressed toggle lights. And the other rule would trigger from the motion sensor. It would be a standard motion sensor/light rule without the ability to turn on the light. It would just turn off the light if it was already on and no motion was sensed for a certain amount of time.

Rule1
Trigger:
button pressed

Actions:
Toggle: light

Rule2
Trigger:
Motion sensor active

Actions:
if light is off exit rule
wait for condition: motion sensor inactive
Wait for event: β€”> elapsed time 0:10:00
off: light

Any time the motion sensor goes active, any waits get cancelled and replaced with new ones. So it won’t turn off the light until 10 minutes after the last active trigger.

Combining into one rule would be possible, but more complex. You would have to have both the button and motion sensor for triggers. You would need to set a local variable to %device%. If that variable is then the button, toggle lights and exit rule. After that would be the actions of the rule2. Seems simpler to do it with 2 simple rules.

2 Likes

I would just use a simple automation for this.

What do you want: turn light off
When : motion in inactive delay X

Done

You could also do the same in RM with just inactive as the trigger and a cancellation at the top.

1 Like

What happens if the countdown starts because of inactivity. The Motion sensor only advertise every minutes not all the time . but there are people in the room?
thank you

Nothing until it gets to its full time out. One the time out elapses. I.e stays inactive for X time and during that time never goes active the lights turn off.

Basically what you have asked for is absence. Manual ON auto OFF. That can be done in the motion app or the simple automation app.

2 Likes

Unless you have no activity for a full 10 minutes, it will never turn off the light. If during the 10 minute countdown the motion sensor goes active, that triggers the rule to run again. That trigger automatically cancels any waits. Which cancels the countdown. The rule then starts a new wait for the sensor to go inactive. When it does, it then starts a new countdown, And if that one gets interrupted by the sensor going active, it gets cancelled too. This continues until you finally get a countdown that doesn't get interrupted by activity for the whole time. Then it will shut off the light. And that's not going to happen if there are people in the room.

That would only work some of the time.
If it went inactive, then the room got real busy so it stayed active for the whole countdown, it would end up turning off the light with people in the room. That's why you need to look at active and inactive in the rule. This is a basic motion sensor/light rule, there are many samples of it in the forum. Many of them don't use waits, they use a conditional statement. If the sensor goes active, turn on the light and cancel any delayed action. Else if the sensor goes inactive start a delayed action to turn off the lights. I used the waits since it does the same thing, but there are less lines to the rule. It doesn't need a cancel, since that's done automatically, and it doesn't need conditional statement lines. But either way the rules work the same, and use both active and inactive to determine when the light gets turned out. And yes, this is simple enough that you could use other apps to do it, and then you wouldn't even need to know how they work,

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