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


#57

Door opens, alert, wait 2 minutes before alerting again whether it’s from a re-open OR left open.

Wife comes in and out with groceries, opens, re-opens the door. Don’t want it to alert every single time, every 2 minutes is enough.

Last trip in she forgets to close it. Also alert me in 2 minutes, over and over until someone closes the door.


#58

edit #2; @DaveinTN try this one instead. Redid my approach without a variable


#59

Going back to the akxj3 example, I’d expect it to loop around giving a notification while the contact is open, but once the contact is closed, it wouldn’t run again. Is that what you found?

The problem is the variable. When you close the contact, the piston starts from the top and the condition evaluates differently, so the wait lower down gets cancelled (sort of - the effect is the same). When you open it again you are stuffed because the variable is false.

Have you tried the piston without the condition testing the variable? I can’t immediately see how it helps. Mind you that makes the whole ‘if’ redundant too. Your problem is being able to differentiate between the door being opened and reopened.

I need to think about this more, but it might be that what you need is a separate ‘if’ and ‘while’ rather than nesting them. The ‘if’ would be something like ‘if contact changes to open and contact was closed for x minutes then push notification’ (where x is however long you consider represents a new open rather than a reopen) and then the ‘while’ would be ‘while contact is open do wait 2 minutes; push notification’.


#60

I hope I am not out of line for jumping in…

All of these are solved in the following piston:

Some of the code above could be condensed a bit, but it helps most people to understand the logic when I break it down like this. (also, the log commands are optional code, and are only there so you can see the logic happening behind the scenes)

Here is a sample output from my testing:
(start reading from the bottom, going up)

pic


The only thing this piston does not do is:

I apologize, but I do not program loops for anyone unless I am “on the clock”.

… but as a courtesy, I would likely put the code for the “Repeat Notifier” in a separate piston.
(totally bypassing any looping, or at most, with a hard limit of 4-5 cycles)

IF Door's contact stays open for 121 seconds
    Then do stuff

Pro Tip:

If you hard code instead of looping, then each notification can be worded more aggressively, with the later one(s) also going to SMS and/or flashing a light in your house to get immediate attention.


#61

wqn2b didn’t work, it never pushed out the 1st notification.

q2uu seems to work for the open/close, however I’m at a lose on what your suggesting for a second Piston.

How does:

IF Door’s contact stays open for 121 seconds
Then do stuff

Repeat without a loop if the door is left open.

Sorry but my scripting skills are limited…


#62

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
Then 
    Send first notification  (friendly reminder)
    Wait 2 minutes
    IF Door’s contact is open             <-- Condition
    Then 
        Send second notification  (slightly aggressive)
        Wait 2 minutes
    END IF
    IF Door’s contact is open             <-- Condition
    Then 
        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
    Then
        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
    Then
        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
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)


#63

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?

Thanks,

Dave


#64

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)


#65

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.


#66

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.


#67

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?


#68

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…


#69

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.

Thanks,


#70

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
Then
    Set door_opened=false
    Cancel all pending tasks
End if

#71

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?

Thanks,


#72

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)


#73

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.


#74

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.


#75

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)


#76

I’ll check it out.

Thanks!