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



Reply to topic  [ 6 posts ] 
 Creating Date/Time Events 
Author Message

Joined: Mar 14, 2008
Posts: 8
Location: Toronto
Post Creating Date/Time Events
Hello, all.

Is there a way to create a date/time action from an applescript. For instance, I would like to create a watering schedule from a web page where the page defines all of the parameters (days of the week, zones, times, etc.) and uses them to create a new date/time action.

Thanks.


Tue Aug 19, 2008 8:04 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6662
Location: Austin, Texas
Post 
Untested:

Code: Select all
tell application "IndigoServer"
   set actionName to "Some Name"
   set actionDescription to "Some autocreated date/time trigger action"
   set actionTriggerTime to "8/20/2008 4:30PM"
   make new time date action with properties ¬
      {name:actionName, ¬
      description:actionDescription, ¬
      time trigger type:absolute, ¬
      date trigger type:absolute, ¬
      absolute trigger time:(date actionTriggerTime), ¬
      enabled:true}
end tell


Note that you can create all the variations of date/time triggers by changing the various properties. Look at the IndigoServer dictionary in Script Editor to see the specifics.

jay


Tue Aug 19, 2008 4:31 pm
Profile WWW

Joined: Sep 11, 2004
Posts: 40
Post 
I am not finding anything in the IndigoServer Dictionary to setup the conditions. How can I make a new time/date in AppleScript and setup the conditions?


Sun Aug 09, 2009 3:43 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6662
Location: Austin, Texas
Post 
trekinsanity wrote:I am not finding anything in the IndigoServer Dictionary to setup the conditions. How can I make a new time/date in AppleScript and setup the conditions?


You currently can't create conditions when creating triggers or time/date actions from AppleScript - the condition will default to "always". There are a few things that you can't do in AppleScript and that happens to be one. It's on the enhancement list however, so it could show up someday but probably not before 5.0... ;)

_________________
Jay (Indigo Support)
Image


Sun Aug 09, 2009 4:09 pm
Profile WWW

Joined: Apr 01, 2003
Posts: 823
Location: Rio Rancho, NM
Post 
I'm essentially using contional time/date actions, but I'm putting the applescript conditions in the excutional part of the time/date action. I start with the following function:

Code: Select all
   on MakeTrigger(TriggerName, TriggerTime, ScriptText)
      tell application "IndigoServer"
         if not (time date action TriggerName exists) then
            set newTimeDateAction to make new time date action with properties {name:TriggerName, date trigger type:absolute, absolute trigger time:TriggerTime, auto delete:true}
            tell first action step of newTimeDateAction
               set action type to executeScript
               set script code to ScriptText
            end tell
         else
            set absolute trigger time of time date action TriggerName to TriggerTime
         end if
      end tell
   end MakeTrigger


Using it might look something like this:

Code: Select all
set devname to "Living Room Lights"
MakeTrigger("_auto_on_" & devname, (current date) + 30, "turn on device \"" & devname & "\"")

It looks messy because of all the escaping of quotes, but I've written some complex applescript using this method including full lists of conditional logic.

_________________
Greg In The Desert


Sun Aug 09, 2009 7:05 pm
Profile WWW

Joined: Sep 11, 2004
Posts: 40
Post 
Thank you both! I was figuring that it wasn't in AppleScript yet. Greg, thanks for the input.


Tue Aug 11, 2009 7:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 2 guests


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.