I’m having some issues with a piston, and I can’t for the life of me figure out why it’s not working.
Here’s the scenario:
Garage light should turn on when entering from either door, or when motion detected. Light should turn off when there is no motion after 1 minute.
Two doors leading to garage, one from the basement, one from outside.
Two door sensors on each door.
One Osram Lightify bulb
One motion sensor (EcoLink)
Here’s the latching piston:
If Any of Garage Entrance or Garage/Basement Entrance contact changes to open
OR
Garage Motion motion changes to active
Then
Using Garage Light, Turn On
But if…
Garage Motion motion stays inactive for 1 minute
Then
Using Garage Light, Turn Off
That seems right… The light turns on, but never turns off. Are there any glaring issues in my code?
I should mention that the EcoLink motion detector has a 4-minute reset time. This might have something to do with it, but I’m not sure.
4-minute reset time on your motion sensor means that it will not show inactive until 4 minutes after last motion active.
So that means Core will not see the motion sensor as inactive until 4 minutes after, then it will start the 1 minute countdown in Core then it’ll turn off the light, total of 5 minutes after.
You’ll need to change your reset timer and remember that the Core inactive countdown does not start until reset timer ends.
You also don’t have anything in there for the doors staying closed in the event that no motion was detected.
I have something similar except for the motion part, but that could be easily added as “or motion is active” (if you try this be sure to use Is and not Changes To). Try something like this:
Only thing I would change on this is to add a Task Cancellation Policy (TCP) on Piston State Change to the Else actions (see my screenshot again). This means that if you re-open a door during the 1 minute delay, the Turn Off command will be canceled. If you don’t do this, the task will not be canceled and you could possibly be back in the garage and have the lights shut off on you.
Also, CoRE doesn’t “check” status, it subscribes to your devices and receives events when the state of any of the subscribed devices changes. So any change in your contact sensors or motion sensor should be pretty close to immediate.