Transition from XTension to Indigo using Apple Script

Posted on
Fri Oct 12, 2012 2:23 pm
RogerPeterson offline
User avatar
Posts: 36
Joined: Oct 01, 2012
Location: Sweeny, Tx, Winter. Atikokan On, Summer

Transition from XTension to Indigo using Apple Script

I am making a transition from XTension to Indigo. Been using XTension forf 12 years and changing entire house (150) devices over to Insteon.
First am changing all X10 devices to run in Insteon.
Have a driveway sensor (O1) That turns on the garage lights (I5) and the Porch Lights Front (A2) if it is dark.

if (status of "Porch Lights, Front") is false and (daylight) is false then
turnon ("Porch Lights, Front") for 5 * minutes
end if
if (status of "Garage Lights") is false and (daylight) is false then
turnon ("Garage Lights") for 5 * minutes
end if

This script has been running great for 12 years, but when I move it to Insteon, it won't run. Gives following error.
Error script error: around characters 83 to 84
Error script error: Expected end of line but found “(”. (-2741)



Any suggestions
Running 10.7.4

Posted on
Fri Oct 12, 2012 3:20 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Transition from XTension to Indigo using Apple Script

Hi Roger, welcome to Indigo and to the forums!

Despite what you may have heard from other sources, Indigo's AppleScript support wasn't a copy from Xtension: your scripts will need to be converted to work with Indigo. You can view the dictionary in the Script Editor application (look for the IndigoServer application) and we've also got it posted online.

Here's an approximate conversion of your script (untested but it should be close):

Code: Select all
if not on state of device "Porch Lights, Front" and not daylight then
   turn on "Porch Lights, Front" for 5 * 60  # the delay is in seconds so multiply by 60
end if
if not on state of device "Garage Lights" and not daylight then
   turn on "Garage Lights" for 5 * 60 # the delay is in seconds so multiply by 60
end if


However - since you are converting anyway, I'd highly recommend that you take a step back and determine if you actually need/want to use a script as you go through converting them. For instance, you can accomplish the above script with two separate triggers. Create a new trigger and configure it like this (things in "quotes" are selections from menus):

Code: Select all
Trigger Tab:
Type:   "Device State Changed"
Device: "Select your motion sensor"
        "On/Off State"
        "Becomes On"

Condition Tab:
"If conditions match rules"
"All"
    "If dark"
    "if device" "Porch Lights, Front" "On/Off State" "is off"

Actions Tab:
Type:   "Control Light / Appliance"
Action: "Turn On"
Device: "Porch Lights, Front"
"Auto-off after 5 minutes"


Repeat for the second light. The advantages are: 1) infinitely more human understandable because you've defined the whole thing in the UI and never had to write any code 2) if you change the name of the device everything will still work.

Again, welcome to the forums!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Oct 12, 2012 3:48 pm
RogerPeterson offline
User avatar
Posts: 36
Joined: Oct 01, 2012
Location: Sweeny, Tx, Winter. Atikokan On, Summer

Re: Transition from XTension to Indigo using Apple Script

Thanks Jay

Posted on
Fri Oct 12, 2012 4:06 pm
RogerPeterson offline
User avatar
Posts: 36
Joined: Oct 01, 2012
Location: Sweeny, Tx, Winter. Atikokan On, Summer

Re: Transition from XTension to Indigo using Apple Script

You guys really made it easy. Thanks

Posted on
Fri Oct 12, 2012 4:08 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Transition from XTension to Indigo using Apple Script

If you haven't already, I recommend that you take a quick run through the Indigo Overview document - particularly the section on Triggers. I don't believe Xtension has the same concept (though I haven't looked at it in a very long time) or Conditions for that matter.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 20 guests

cron