This followed by that?


#1

I am trying to do a if x happens and then y happens do z

Like for example: If Motion is detected at the stairs and then motion is detected in the living room (downstairs), then turn off the upstairs hall light (because you went down the stairs, clearly).

And to make sure it does not happen if you go living room motion then stair motion

I have been toying with the group of “followed by” function but it does not seem to work


#2

Why not just turn off the upstairs hall light if there’s no motion?
Here’s a piston I use for my upstairs hallway lighting. I use a motion sensor at the bottom of the stairs, and an additional one at the top of the stairs facing the bedroom doors (not sure of your house layout so it may not work for you).


#3

The other thing to consider with your original idea…

What if you were walking up the stairs a few moments before your partner (or pet) walked into the living room. You would be left in the dark because ST cannot tell who is who.

I have occasionally programmed for two motion detectors on a stairwell (one at the top, and one at the bottom). Using variables, webCoRE can usually distinguish what direction you are going in… but it gets tricky if multiple people trigger sensors near the same time period. (it works best when the sensors cover as little area as possible - I often install an inch above the the 2nd step for this case - Aimed away from traffic)

I would lean towards a slight modification to @allrak’s suggestion.

IF motion is inactive for X minutes
Then turn off lights

The less ‘grey’ area, the more reliable your outcomes.


#4

well I have a way to deal with that as well. if the motion is detected upstairs, it turns on a variable to say “yo someone is here” along with a countdown timer until more motion.

the this followed by that will just cut the motion countdown if you do walk downstairs. At that point it’ll start a 1 min countdown for the light upstairs.

It’s what I have to do to deal with cheap Xiaomi sensors that only detect motion every 60 seconds.


#5

it all works great, the only problem is when it detects something out of order, it restarts the piston which is annoying

If motion is detected at X followed by motion detected at Y, then do whatever

if motion is detected at Y without motion at X, it restarts the piston. Which is fine if that’s all my piston contained. I will jsut have to make a new piston. I hate having 50+ pistons!


#6

Each time a trigger happens, the code runs all the way thru… top to bottom.

Perhaps putting that code in a separate piston will give you better results.
(don’t forget to share your work when you are happy so others can benefit)


I have 249 pistons in my house right now…
although about 100 of them are just used as examples, and are kept paused.

Categorizing your pistons makes it MUCH easier to keep track of them.
Dashboard > Settings > Categories