Notify if door open for x amount of minutes


#1

Hello, I’m trying to configure the piston to send an SMS if either the front or back door has been unlocked longer than 10 minutes (testing with 1) and continue to repeat every 10 minutes.

It should send the SMS saying ‘The x door has been unlocked since (time)’

However when I receive the message it always gives the current time rather than when the door was unlocked, I assume there is a global variable such as $device:laststatechange or something similar but struggling to find anything.

Cheers,


#2

What about inserting the code below as the first IF to store the current time when it was unlocked.

If Any of Back Door or Front Door’s lock changes to unlocked
Set variable StartTime = $time


#3

Genius thanks mate, put that logic in at the top and all working now :slight_smile:

Much appreciated.


#4

Ash do you mind sharing your code for this? Thank you.


#5

Sure no worries, find below :slight_smile:

cheers,


#6

Just a question for you.
Did you try using ‘While’.
WHILE
Door is unlocked.
DO
Wait 5 minutes
Send SMS
Wait 25 minutes.
Put in various other stuff that you want.
This with continue to cycle round all the time the while is true.
This is how I report Gate and garage doors being left open.
Just another way of skinning that cat. :wink:


#7

I hadn’t, very true though, would probably make for a shorter/neater script to be honest… have created it so will give it a go! cheers,