Comparing Indigo Time Variables

Posted on
Fri Nov 23, 2018 10:40 pm
mattyf offline
Posts: 58
Joined: Apr 15, 2013

Comparing Indigo Time Variables

I have an Applescript to send me a pushover notification if my garage door has been open for over 30 minutes.

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

Posted on
Sat Nov 24, 2018 5:33 am
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Re: Comparing Indigo Time Variables

This Applescript you run every 30 minutes, why don't you replace it with an action group running a script like:
if garage door is open then
send notification
execute group 'this action group' in 600
end

This way you don't need calculation, every 30 minutes you will get a notification and it will stop when the garage door is closed...
Pushover runs very well for me, make sure you fill all the fields in the notification like Title and Message, it doesn't work well if they are empty.

Posted on
Sun Nov 25, 2018 1:48 pm
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Comparing Indigo Time Variables

Another non-script option is to use a Timer - start it when the door opens, cancel it via a trigger that fires when the door closes, and notify via trigger when the timer expires. No script.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Nov 25, 2018 2:32 pm
mattyf offline
Posts: 58
Joined: Apr 15, 2013

Re: Comparing Indigo Time Variables

Yes, thank you both. I realised I was kinda overcomplicating things.

:)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 8 guests

cron