Whenever the garage door is opened, I have Indigo place the time it opened into a time variable called TimeGarageOpened.
If the garage door is currently open, Indigo runs an Applescript every 30 minutes. It compares the door open time to the current time, and sends the notification via a curl command (The pushover plugin won't work for me and I don't know why.)
Any help would be appreciated... I got a LOT of help on the Applescript from an AS forum....
- Code: Select all
tell application "IndigoServer"
set doorOpenTime to value of variable "TimeGarageOpened"
set indigoCurrentTime to value of variable "CurrentTime"
end tell
set OpenTime to current date
set CurrentTime to current date
dateObject from doorOpenTime into OpenTime
dateObject from indigoCurrentTime into CurrentTime
set timeDiff to CurrentTime - OpenTime
set myResult to timeDiff / minutes
log myResult
if myResult > 30 then
do shell script "curl -s --form-string 'token=xxxxxxxxx' --form-string 'user=xxxxxxxxx' --form-string 'message=Matt- The garage door has been open for more than 30 minutes. Love, Kevin.' https://api.pushover.net/1/messages.json"
end if
to dateObject from theDateString into myDate
set {oti, text item delimiters} to {text item delimiters, " "}
set {dateString, timeString} to text items of theDateString
set text item delimiters to ":"
set {hrs, mins} to text items of timeString
set hrsMins to hrs * hours + mins * minutes
set {yr, Mnth, dy} to words of dateString
set the time of myDate to hrsMins
set the year of myDate to yr
set the month of myDate to Mnth
set the day of myDate to dy
set text item delimiters to oti
end dateObject