Make multiple motion sensors behave like a single sensor?

Hi all,

Looking for a bit of advice on a SmartThings setup, Aeotec hub and Aeotec motion sensors.

I’ve got an open-plan kitchen and extension with a kitchen island splitting the space. I’ve put one motion sensor on each side, one covering the kitchen and one covering the extension and they don’t really pick each other up because of the island.

What I’m trying to achieve is simple: any motion turns the lights on, and then they turn off 5 minutes after no motion.

I’ve tried this two ways:

First attempt was a single routine where either sensor would turn the lights on, then delay turning them off for 5 minutes. My thinking was that each new motion event would effectively “restart” that 5-minute timer, so the lights would stay on no matter which side I was in. In reality, I was getting random shut-offs.

Second attempt was splitting it out, lights turn on with any motion, and then a separate routine turns them off only when both sensors have had no motion for 5 minutes.

Now the opposite problem, the lights don’t seem to turn off at all. My assumption is that if I don’t walk past one of the sensors, it never reports “no motion”, so the condition is never met.

Is there a way to make multiple motion sensors behave like a single sensor for this kind of setup?

Rough diagram to visualise:

Advice appreciated :slight_smile:

Directly in the motion sensor’s “Routines” tab, there’s a simple way of turning lights on and back off after an adjustable time. These routines are different from anything you can build manually.

If you address the same lamp from this mechanism in both sensors, that should do.

Edit: It might not, because if one sensor saw motion and then you move to the other half of the room, the first one might still turn the light off. Try it out.

Edit #2: You may want to do this with presence sensors. When everyone has sat down for dinner, you’re going to need a very lively dinner to keep a motion sensor entertained.

Either way - have you tried putting the motion center on the ceiling, dead center?

Edit #3: Apparently sensor groups should be a thing.

Interesting problem.

I’d try

  1. Single routine to turn lights on with motion on any motion sensor as the condition
  2. Separate routine to turn lights off with lights on as a precondition and no motion for 5 minutes on all sensors as condition.

Are you turning on multiple lights/switches or just one? Getting the conditions right might be tricky with multiple lights.

1 Like

You can use a virtual switch to merge both motion sensors in one, following this approach.

  1. Create a virtual switch (I’ve tested with a local one, I guess it will work with cloud based too)
  2. Create a routine “If switch on for 5 minutes Then turn switch off”
  3. A routine when motion is detected by any sensor, turn the switch on (this restarts the 5 minutes timer) and the lights of course.
  4. A routine when the switch is off, turn off the lights. This will only happen if no sensor has detected motion in the last 5 minutes.
4 Likes

Thank you for the reply, I did start with this approach however lights were turning off randomly even with me in either one of the rooms, not sure how it works in the background but my best guess was a 5min timer was still kicking off as a seperate job and my routine wasnt rearming the same timer, but not really sure why it didnt work.

Thanks, I did try this too however the off part never worked, for some reason the condition that both sensors must not have motion never triggered, maybe because I never walked past one of the sensors to trigger a motion so it did not register a “no motion” event either.

You don’t mention a virtual switch in your text or in reddit, if you tried with “lights on for 5 minutes” it won’t work. Has to be the virtual switch that forces a state change even if it’s the same.

Also make sure you don’t use delays but the “stays on for 5 minutes”.

And triple check there are no more routines running of previous approaches.

You don’t mention a virtual switch in your text or in reddit, if you tried with “lights on for 5 minutes” it won’t work. Has to be the virtual switch that forces a state change even if it’s the same.

Also make sure you don’t use delays but the “stays on for 5 minutes”.

And triple check there are no more routines running of previous approaches.

Ah, thank you for the reply, originally in testing I had tried the approach that motion on any of the 2 motion sensors triggers a virtual switch to be turned on, however in that same routine there was a delay for 5 mins then turn off, my thinking being any time motion was triggered it would trigger the routine again which gives me another 5 mins, I still dont quite understand why this didnt work and would love to know just for curiousity.

Reading your post I have now got rid of that delay and just got a seperate routine as per your point 2 just to turn off after 5mins, also followed the rest of the steps, i’ll know this evening whether it has worked, certainly makes sense what your saying so I am more hopeful now :slight_smile:

Delays are evil because you can’t cancel them, if you have a delay and an action, the action will always run after the delay.

Every time there was motion you were scheduling an unconditional off 5 minutes later. That “random off” was not really random, happened 5 minutes after one of the previous times a sensor detected motion.

Yes, logic error.

You wanted two independent things -

if (motion) then
lights on

if (no motion for five minutes) then
lights off

but you actually coded one sequence -

if (motion) then
lights on
wait five minutes
lights off

These two things are not the same. The secret is to code the delay into the condition, not the action.

So what you do is -

One routine for On - condition one of Sensor1 motion or Sensor2 motion, action lights on.

One routine for off - condition both of sensor1 and sensor2 no motion for X amount of time, action lights off.

Thank you both, that does make sense but it still does not seem to be working for me, light still switches off while active in the kitchen, strangely when it turns off, even more motion in the kitchen doesn’t trigger the light again, have to move to the other motion sensor to trigger lights to come on again.

Some screenshots, can’t tell what is going wrong, I am using smart lighting to turn lights on but guessing that should not matter:

Any ideas would be appreciated, the wife is not happy :grinning_face:

What is or isn’t happening and when?

It would help to see the device histories of the motion sensors and the virtual switch as there has to be repeated on events to keep the five minute timer refreshed. That isn’t something just any virtual switch can do, so can you confirm how you are creating it?

That said, I’m a little surprised that the simple two Routine approach described in the post above and the two posts below doesn’t work. I could understand there perhaps being issues immediately after saving the Routine until both motion sensors have cycled (it isn’t clear how Routines are initialised) but that’s about all.

The picture is too small to read. Have you tried a simple setup with:

If Light is off (precondition)
   Motion on SensorA or Motion on SensorB
Then
   Turn on Light
If Light is on (precondition)
   No Motion on SensorA for 5 mins AND No Motion on SensorB for 5 mins
Then
   Turn off Light

I think the case is very easy as I have many room setup with multiple motion sensors first for turning on you have to set all your motion sensors but chose when any condition below is met, now for turning off create routine put all your motion sensors but chose (when all conditions below are met)

Actually @HalD , @h0ckeysk8er and @raed.jarrar are correct, there’s no need for the virtual switch at all!

I wasn’t very confident about the behaviour of the “for 5 minutes” so I’ve tested it and looks like it works.

The generated rule “stays for 5 minutes” translates to a remains condition with latching: true, not really sure how this modifier affects the remains behaviour but seems like that’s what makes it work in this case. I guess the latch is what makes it stay in that condition so even if both sensors meet the condition at different times it will trigger the routine. Without the latch, I guess, the routine would not work.

2 Likes

Exactly. The logic I gave further above, which is the same as h0ckeysk8er just reiterated, will work. I tried this same setup in my hallway and staircase - light turns on when either upstairs or downstairs motion sensor detects motion; light turns off when both sensors did not detect motion for X amount of time. No other helpers, tricks, or virtual devices required.

As ever, the API Reference is really only useful to those who already know how latching works (so not me). My best guess is that the remains condition defaults to only returning true once, and then reverts to false which is probably fine if remains is your only triggering condition but doesn’t seem the most useful behaviour as you probably want it to retain its last state much of the time (hence the latching option). It’s the difference between ‘there hasn’t been any motion for five minutes’ as a one-off event, and ‘there hasn’t been any motion for five minutes or more’ as an ongoing condition. To me the default and optional behaviour seem AOT but I am sure there is a sound reason for it.

It never affected me as I was a relatively early adopter of the Rules API and that allows me to aggregate motion sensors and use a single remains. In any case latching was never an option and I still don’t use it (I think it was only documented relatively recently).

Yeah, that’s my guess too. The remains condition once true will stay true until invalidated, that’s why it works with two conditions, otherwise it wouldn’t.

I have also tested “no Motion on SensorA for 5 mins AND No Motion on SensorB for 5 mins” however in that case the lights never turn off, my best guess was because I dont walk pass sensorb sometimes it never sends a “no motion” event so the lights off routine never triggers, sometimes I only enter the kitchen/sensor A and leave the room.

That should only be a plausible explanation if, since starting the Routine (saving or enabling), you haven’t walked past sensor B, left the room, waited for it to report ‘no motion’, and then waited another five minutes. Until you have the ‘no motion of sensor B for 5 minutes’ condition will not be true and the Routine will not do anything useful. Once you have the sensor A activity by itself should eventually trigger the Routine.

As long as you haven’t stopped the Routine, it should also only be a problem once.