Another Motion Challenge (Sorry)


#1

1) Give a description of the problem
I want to create a motion trigger for my stairs that turns the lights on and then turns them off after a set time. This has been somewhat successful with my two motion sensors, one at the top and one at the bottom. The issue I am running into is with turning them off. I create a trigger that checks both sensors are inactive for at least 15 seconds and then the piston sets the wakeup time. However, if motion changes back to active within that wakeup timer, the piston still executes the off command for my lights. I looked into the task cancellation policy and maybe implementing some sort of loop to fix this, but am coming up empty handed. Below I will list the ideal scenarios, any guidance would be greatly appreciated.

2) What is the expected behaviour?

Senario A.

1). Motion is inactive on both sensors for 15 seconds.
2.) Wakeup time is set.
3.)No motion occurs and lights off command is sent.

Senario B.

1). Motion is inactive on both sensors for 15 seconds.
2.) Wakeup time is set.
3). Motion changes active within the wakeup time, task cancelled.
4). Once motion is inactive for 15 seconds the turn off of the lights is allowed to move forward.

3) What is happening/not happening?
Action is set to default task cancelation, but motion changing to active does not cancel the task, lights turn off anyway.


#2

I just want to clarify what is happening behind-the-scenes:
(the wakeup is scheduled the instant they turn inactive, not 15 sec later)

Scenario A.

1). Motion is inactive on both sensors
2.) Wakeup time is set for 15 seconds.
3.) No motion occurs and lights off command is sent.

Scenario B.

1). Motion is inactive on both sensors
2.) Wakeup time is set for 15 seconds.
3). Motion changes active within the wakeup time, task cancelled.
4). Once motion is inactive on both sensors, jump to Scenario A


You did not post your current piston, but this usually means you have too many triggers in play.
(generally speaking, STAY triggers need to be separate from other triggers)


#3

Thanks as always!

My language might have been misleading, but I do understand the wakeup is scheduled when they turn inactive. I am posting a snapshot of my piston now. As you mention triggers, It is true I have the off statement as an “else if” below the two statement that turn on the lights. Perhaps this is a reason?

Just so I understand, once a wakeup is scheduled its impossible to stop the following tasks if a condition changes? This is where I was trying to figure out if waking up and using a loop to check a condition might come in handy.


#4

I am not trying to be nosy, but can you insert fake names next to the sensors so I can see how many devices you are referring to, and their relationship to each other?

I am assuming something like this:

pic


For what it’s worth, the STAYS INACTIVE block should be a separate block.
(not sure about the other ELSE IF until you answer my above question)


It is normal (and easy) to abort when a condition changes.
(if you avoid ELSE IF and make independent blocks instead)


#5

Update- Moving it to its own block works great it seems!

You are correct in your assumption on the devices and their relationships.

The “else if” is to stop a re-trigger, not that it really matters I suppose.However, I was trying to be efficient by not making two calls to the Piston when I really only need one depending on the direction I am going on the stairs

I will start by making the statement for the motion inactive its own block.


#6

Sweet!


I do not see anything in your code that encourages a double trigger.
… and splitting into separate blocks will not create double triggers either.
(although keep in mind that either device can still do that)

Basically, an “ELSE IF” can not stop a second trigger. If there is a lightning bolt in the left margin, then whenever that device’s attribute changes, the piston will run top to bottom.