Please help me debug

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.

Thanks for the help!

Did you try using Core or Stringify to preform the integration?

This is using CoRE

For the heck of it, try two pistons…one for turning it on when motion active, one for turning it off when the sensor goes inactive. See what you get.

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:

Thanks for the help all! There are many ways to skin a cat. I’m still a beginner, but all this makes great sense.

Here’s what I’ve got going on now. It seems I have the same garage as destructure00, so I just added a motion detector to it:

I think using “Is” instead of “Changes to” is key here… Now I wonder, how often does CoRE check status?

2 Likes

Using multiple conditions in CoRE is acceptable. Using multiple triggers causes issues when under the same IF.

If you have only conditions then they subscribe to those devices. So they see changes immediately and CoRE reacts.

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.

1 Like

Brilliant, thanks! I never would’ve figured it out if the lights had gone out on me.

1 Like