Turn On by Motion / then Off after Period of No Motion?


#1

[pretending I don’t have anything created yet, and have no idea what I’m doing]

I want to create a Piston that will do the following…

  • Only while the system is in any of these modes (MODE1, MODE2, MODE3)

  • If Motion becomes active on any of these motion sensors (MOTION1, MOTION2, MOTION3, MOTION4)

  • Then turn SWITCH1 on

  • [Only while SWITCH1 is on] If all of those same four motion sensors as above stay inactive for 30 seconds

  • Turn SWITCH1 off

i.e. If motion were to happen again during the initial 30 second period, it should ‘reset’ the timer, and the Piston should start waiting for 30 seconds again; and so on, until these four motion sensors finally stay inactive for a contiguous period of 30 seconds.










Here is what I originally typed (so don’t go by this section; I’m just including FYI), but then figured I should make it more like the above lol …

This might just be me venting my inner frustration with how stupid I am…I haven’t decided yet…

In ROOM-1, I have some ‘things’ (a light fixture connected to a smart switch, and some motion sensors) and an automation (a Piston in webCoRE) humming along just fine.

In ROOM-2, I have basically an exact copy of those ‘things’ as in the automation in ROOM-1.

I have tested all of the ROOM-2 ‘things’ (together and individually), and found them to all be working properly.

I used webCoRE to create a new Piston in ROOM-2 by duplicating the one mentioned above in ROOM-1.

I went through and modified the newly created Piston in ROOM-2 to use the ‘things’ in ROOM-2 instead of the ROOM-1 ‘things’.

However, the new Piston doesn’t work.

I’ve already boiled it down quite a ways to simplify it as much as I think I can, but what should be my process of troubleshooting?


#2

Seems relatively easy to make this happen, can you post a green snapshot of your pistons for review?


#3

Right lol
That’s what I was thinking.

I can’t at the moment, but I will when I get back here a little later.

Thanks. :slight_smile:


#4

If nothing else import this one and see if this works for you. it will prompt you to fill out the variables with your own devices. I used a dimmer for now in place of a switch but it would work the same, also you can add multiple switches in that case.


#5

What is the function of SWITCH1???

Something like this will do it…

IF any of motions sensor 1, 2, 3, 4 CHANGES TO ACTIVE (trigger)
AND
IF mode is any of 1, 2, 3
Then 
Do turn on lights

IF all motions sensors 1, 2, 3, 4 STAYS INACTIVE 30 seconds
Then 
Do turn OFF lights

#6

Yep. As with many Pistons ive created since starting to use webCoRE when it was first released, thats exactly what i did here, but for some reason, its just not working.


#7

Ok…here’s a green screenshot of a test piston…

If i simply turn the switch on, and do nothing else (i.e allowing the motion sensors to sit inactive), it turns the switch back off after 10 seconds.

However, if i cause motion on any of the sensors within the first ten seconds after turning the switch on, it acts as though I’ve paused or halted the Piston in that it doesnt turn the switch back off…ever.


#8

Thanks.
I will test that one next, and report back…


#9

If i’m not mistaken,
this piston is using 2 triggers and almost impossible to execute because what you are saying in here is,
IF switch changes to on, all other sensors simultaneously must be inactive for 10 seconds so that it can execute… if one of them was inactive 9 seconds or 11 seconds it won’t execute.


#10

Ya, I just hurried up and created that piston as an example. I didn’t really think about it before I posted it.

I’m just about to test the example piston posted above…


#11

@SergL

I imported that example piston, and it seems to be working properly.

I even added an ‘Or’ by adding a switch turn on as a second potential trigger (so I could test it without going into that room every time), and both it and the motion trigger work.

The only thing I can’t seem to get working is to have the timeout be 10 seconds (instead of 30). Oh well. No big deal.

So, thanks for the assist.

Now…the goofy part is the fact that this is pretty much exactly what I had created previously (well, I had all components written directly into the flow of the rest of the code, and not using placeholders/variables, but I assume that’s irrelevant) which wasn’t working. lol

I guess I will go through each of them, line by line, to see if I have something goofed up in my original. :slight_smile:


#12

A piston 10 seconds or less does not always follow the same logic as pistons 11 seconds or longer. This is because after 10 seconds, the piston stops, and schedules a wakeup to continue. At that point, a few things happen differently.

In other words, you might find 12 seconds to work for you.


#13

@WCmore

Sweet! Thank you. :slight_smile:

Funny thing is that the main reason I ever use timing that short is for testing; i.e. I just don’t like waiting a long time (30 seconds, a minute, five minutes, hours, etc) for things to happen like they normally will when the automation is done being created and tested, and is in place as a normal part of my system.


#14

I don’t know if you will find this helpful… but when testing delays:

IF the final version will be longer than ten seconds, my tests are 12s or more
IF the final version will be shorter than ten seconds, my tests are 8s or less

This basically ensures the same logic is processed during testing AND the finished product.
(I avoid the 8-12 sec range so lag cannot cause any confusion)


Edit:

IF the final version will be shorter than ten seconds
I usually just keep it the actual (final) number when testing


#15

Awesome! Thank you. :slight_smile:


#16

Thanks for everybody’s suggestions, and assistance on this.
Here is what I arrived at. It seems to be working like this.


#17

Looks like its working well. Good to hear.