View unanswered posts | View active topics It is currently Fri May 24, 2013 7:51 pm



Reply to topic  [ 5 posts ] 
 Garage door monitor 
Author Message

Joined: Jul 15, 2007
Posts: 89
Post Garage door monitor
Hi!

I'm trying to monitor my garage door.

I have a variable that is "DSC_Garage_Door_Monitor" which contains the time when the door was opened, and the following in the conditions section.


Code: Select all
set alarmtime to (time of (current date)) + 180
set openedtime to time of date (value of variable "DSC_Garage_Door_Monitor" as string)
if alarmtime is greater than openedtime then
   return true
else
   return false
end if

it should return a true signal if it's been more than 3 minutes

I don't understand why this is not working any tought?


Sun Dec 18, 2011 8:41 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6665
Location: Austin, Texas
Post Re: Garage door monitor
I don't know what the value of "DSC_Garage_Door_Monitor" is, so it could be that it's not getting converted to a date properly. Strings to dates in AppleScript are incredily tricky.

You might also want to try changing the second line to:

Code: Select all
 set openedtime to (time of (date (value of variable "DSC_Garage_Door_Monitor" as string)))


just to make sure scoping is correct. Don't know if that'll help though, my guess is converting the string to a date object is failing somehow.

_________________
Jay (Indigo Support)
Image


Sun Dec 18, 2011 1:03 pm
Profile WWW

Joined: Jul 15, 2007
Posts: 89
Post Re: Garage door monitor
Will try it

The value of "DSC_Garage_Door_Monitor" = applescript current date function

jay wrote:I don't know what the value of "DSC_Garage_Door_Monitor" is, so it could be that it's not getting converted to a date properly. Strings to dates in AppleScript are incredily tricky.

You might also want to try changing the second line to:

Code: Select all
 set openedtime to (time of (date (value of variable "DSC_Garage_Door_Monitor" as string)))


just to make sure scoping is correct. Don't know if that'll help though, my guess is converting the string to a date object is failing somehow.


Sun Dec 18, 2011 2:14 pm
Profile

Joined: Jul 15, 2007
Posts: 89
Post Re: Garage door monitor
The final working script for whoever wants to have time based conditional

Code: Select all
if the value of variable "DSC_Garage_Door_Monitor" is not "Porte de Garage Fermée" and the value of variable "DSC_Exterior_Temp" is less than "005" and (date ((current date) as string)) - (date (value of variable "DSC_Garage_Door_Monitor" as string)) is greater than 180 then
   return true
else
   return false
end if

This will first check if the garage door is close then check if the temp is below 5 celsius and finally if it's been opened for more than 3 minutes....

This all intertwine with the other script that I modded a while back
http://www.perceptiveautomation.com/userforum/viewtopic.php?f=6&t=875


Mon Dec 19, 2011 7:13 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6665
Location: Austin, Texas
Post Re: Garage door monitor
I don't think you need to do this:

Code: Select all
(date ((current date) as string))


It's doing an unnecessary conversion - "current date" will return a date object which is what casting a string to a date returns. Just use "current date"

_________________
Jay (Indigo Support)
Image


Mon Dec 19, 2011 7:25 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.