Alert when door sensor is tripped, then wait 2 minutes before alerting again


I was suggesting a hard coded solution for a set number of notifications.

The following basic structure may look primitive, but I find it to be more customizable, with zero chance of an infinite loop.

IF Door’s contact stays open for 121 sec  <-- Trigger
    Send first notification  (friendly reminder)
    Wait 2 minutes
    IF Door’s contact is open             <-- Condition
        Send second notification  (slightly aggressive)
        Wait 2 minutes
    END IF
    IF Door’s contact is open             <-- Condition
        Send third notification  (stress the urgency)
        Flash (centrally located light) briefly
        Wait 5 minutes   (notice I changed this)
    END IF
    IF Door’s contact is open             <-- Condition
        Send fourth notification  (Get off your butt!)
        Flash one light in each of the main rooms
        Voice Alert (Alexa/Google/Sonos etc)
        Wait 5 minutes
    END IF
    IF Door’s contact is open             <-- Condition
        Send fifth & last notification  (slowly drags index finger across throat)
        Turn on one light in every room
        Send Urgent SMS to home owners
    END IF

Pro Tip:

The last block can also send a SMS to a trustworthy neighbor… In case the logic gets that far down in the code without the door closing. (although I would not add that code during testing, LOL)


This seems to work!

I only did 4 cycles and I’ll have to work on the Alexa integration, haven’t ventured that far yet.
Nor did I see a way to add my ST plug in outlet as an action. I see LIFX listed. Would I need to call another Piston?




Lookin’ good!!

I must have missed that part of the conversation… What is your plans with that device?
(It’ll probably go in one of the pistons we just made)


You mentioned flashing lights. I have a Smartthings plug-in outlet that my office lamp is on. Didn’t see how to add a line to flash it.

I have the Alexa Smartapp added, just haven’t looked for any examples yet.


Ahh ok… If you don’t have any smart bulbs, then the best flash might be simply:

Turn on
Wait 2 secs
Turn off

Here is how I get Alexa to give me voice alerts.
(takes 20-30 min to setup, but only 2 seconds for all future voice alerts)

The good news is, with the above structure, you can add more commands to it as your house gets smarter.


I still don’t see where to add reference to the light. If I click on new task say below “Send PUSH notification” the only thing close is execute piston. I don’t see the option to interact with a device directly at that level?


Inside the appropriate block, click on:

+ add a new statement > Add an action > then choose your outlet > add a task > select a command

The rest should be familiar…


got it, I was looking at the + add a new task above it, thinking the + add a new statement was outside of the current action…I think keeping the nesting straight is my biggest challenge.



I think I understand what happened. If you closed the door and reopened it before the 2 minute timer was up, it likely interrupted the piston and the Boolean never got set back to false, would need to add protection for that case. I would suggest adding another trigger like this to the end of the piston:

If contact sensor changes to closed
    Set door_opened=false
    Cancel all pending tasks
End if


The door open/close pistons have been working, however as of a few days ago my push alerts have been delayed. I’m talking over a minute later I receive the alert.

I’ve tried rebooting the hub and it’s still randomly delayed.

Is this a Smartthings issue or something to do with Webcore or both?

Does Webcore run locally on Smarthings or does it still have to go to the cloud to run?

I’ve recently been looking into Home Assistant and I’m seriously considering moving to it so everything runs locally. Anyone have any experience with it?



This is not normal. Can you share the piston that is sending delayed PUSH notifications?

Side Note:

If all of your pistons are sending delayed PUSH notifications, then rebooting your cell phone can make a big difference. (since that is the device that receives the PUSH)


Rebooting didn’t fix it but it did lead me to test a bit deeper. Turns out I only had the old ST app alerting (store messages set to false) from when I was testing and the app somehow got set to go to sleep. I turned sleep off and flipped the flag to true so I get all the alerts within a second or two.

How I just have to figure out what’s up with my Meross Garage door authentication. Support is useless. Starting with the last ST upgrade my authentication drops out every few days and I have to re-authorize it.

Any comments about Home Assistant?

Thanks for the help.


Now what would really be cool is if I could get different alerts for each action played by my phone.

Door opens - Door open/close sound

Garage opens - an announcement that the garage door has opened or some other recognizable sound.


If your phone is Android, then Tasker can do all of that, plus so much more!

(without a doubt, it was the best $3 I spent in the past decade)


I’ll check it out.



If you end up going with the Tasker approach, I would also recommend installing a free “media grabber” like Zedge to download cool sound effects. If you can deal with their ads, their search is phenomenal…

(Notifications are usually short, while Ringtones are usually longer in duration)

Once you have the sound effects downloaded to your phone, then Tasker can call those sounds effects whenever ‘X’ happens.


So I am looking at this again…If I understand this code correctly, this is a brilliant solution for avoiding loops.

If the door stays open for 121 seconds, then execution will cascade down this piston (top to bottom) with each successive IF and WAIT, sending an alert, waiting, and then moving to the next IF/WAIT and sending a more aggressive alert. If the door closes, then the current WAIT is cancelled and the piston is executed from the top again. This time, the door is closed, and execution is completed. So the TCP could be left at default for each WAIT.

Am I understanding this correctly?



Absolutely… I might even go as far to say that it should be left at default.

(here is that full post for reference)

Pro Tip:

You will probably not want to add more triggers to this piston though…