Turn on Lights on Motion when moving from one room to another (motion detected within x seconds of preceding motion sensor)


#1

I am trying to design a Piston that turns on the bedroom light on motion, however I want to ensure that the lights only turn on when I walk from the Hallway to the Bedroom.

My code is below, to provide some narrative:

Motion Sensor 8 and Motion Sensor 11 are rooms which lead to the bedroom (Motion Sensor 10).

The 10 seconds allows for a bit of dwell time moving between the rooms.

Motion Sensor 13 is only used for Lux measurements - it is queried by all lighting pistons to ensure that the lights only come on when it is dark (it is outside of all the rooms in scope for motion).

Is there any glaring issues anyone can see please?

Best wishes
Guy


#2

Could this be something that you are looking for.


#3

Hi Bobbles,

I did try that SmartApp, but I found it very confusing to set up - it is also a bit overkill for what I need to use, I’m hoping some complex/simple logic with the Piston may be able to overcome my issue.

Thanks,
Guy


#4

I looked at it but haven’t used it either. No real need for it.
I also haven’t used ‘Followed by’ either but looking at your piston I see no reason why it wouldn’t work


#5

Sure, perhaps I need some time to leave it to bed in (I have been walking in and out of that room so many times this weekend).

After finding out about WebCoRE and how flexible it is, I now want to do everything through it :slight_smile:


#6

Line 19 is not subscribed so will never fire the piston.

This is because you are mixing conditions and triggers… in which case only the triggers subscribe.

Change line 19 to a trigger (changes to) or change line 21 to a condition (IS).


#7

What Robin said…or you could flip it around…

IF Bedroom motion sensor changes to active
AND
Any of the other 2 motion sensors is active
Then…

This way you ARE using the other 2 rooms as a Condition and the bedroom one becomes the Trigger.

As long as you can get to the bedroom before the any of the other motion sensors time out you’ll be all set.


#8

if you need any help setting up rooms occupancy please feel free to ping me and i will be happy to help.

its the 1st room that usually takes a little time to understand the concept after that the remaining rooms seem to go easy for users. there is also the question of does the user really need all of the capabilities of the smartapp and the automation it enables. if not piston is the way to go. :slight_smile:


#9

Hi Bangali,

Thanks for your offer of help - will give the Piston a go and will probably try and tackle the SmartApp when I have a week or so off work (for play time!).

Thanks Robin and Mike for your input (and thanks Mike again - after your help a couple of days ago!) - I’ve tweaked the Piston and will see how it runs. Once I’ve got it working I’ll post it up here so anyone else looking for a similar use case can borrow it.

This forum is brilliant, everyone is so eager to help - this is a great project and community (I’ve donated as a token of my appreciation).

Best wishes
Guy


#10

Hi all,

I’ve tweaked the code as for some reason the condition with the Motion Sensor in the Bedroom was getting stuck during execution - meaning that the light would come on when moving around outside the room.

My next piece of work is to add a wait period for when the rule runs, so that the light doesnt come on if someone turns it off at the switch and someone moves in and out the room within a 5 minute period (like what my partner does when he gets dressed for work in the morning).


#11

I don’t think what you have there will actually prevent the light from coming back on within the 5 minute period. What’s likely going to happen there is that a new instance of that piston will spawn up when all of those conditions are met. So…you need to restrict the piston from running by adding a time based condition (or at least that’s the way I’d do it).

See example #4 here:


#12

I thought as much, that I would need to implement some kind of Time Cancellation Policy. Will wait for sunset tonight and give it a try :slight_smile:


#13

Hi Mike,

Again, great help - implemented the 5 minute wait time and the finished code is here:


#14

Guy, what sensor are you using for lux?


#15

Hi Lisa,

I’m using an Aeotec MultiSensor 6 (https://www.amazon.co.uk/Aeon-AEOEZW100-Labs-Multisensor-Z-Wave/dp/B0141FQDJQ/ref=sr_1_1?ie=UTF8&qid=1527070432&sr=8-1&keywords=aeotec+6)

Best wishes
Guy