[ANSWERED]: Example AppleScript to turn device on and off

This subforum has been locked since we no longer support AppleScript.
martinc
Posts: 83
Joined: Thu Oct 27, 2005 3:06 pm

[ANSWERED]: Example AppleScript to turn device on and off

Post by martinc »

Hi,

I am very new to AppleScript but what I am trying to do it make an Apple Script that when run would set a device (lets say A1) to on or off, Could you please show me the code for this?

Thank you very much.

What I am trying to do is have Keyspans Express remote when pressed run an Apple Script to turn Indigo items on/off dim etc.

Thanks again.
User avatar
matt (support)
Site Admin
Posts: 21476
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: AppleScript to set an Indigo device to on and off

Post by matt (support) »

You can use AppleScript to send raw X10 commands (A1 On), but I would recommend doing it by the device name in this case. Something like this should work:

Code: Select all

tell app "Indigo"
  turn on "office light"
end tell
Regards,
Matt
martinc
Posts: 83
Joined: Thu Oct 27, 2005 3:06 pm

Post by martinc »

OK will give that a try.

Can you dim aswell?
What would that script look like?

Thanks
User avatar
matt (support)
Site Admin
Posts: 21476
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Post by matt (support) »

Definitely. Looks like this:

Code: Select all

tell app "Indigo"
  brighten "office light" to 75
end tell
The complete AppleScript dictionary is available here.
martinc
Posts: 83
Joined: Thu Oct 27, 2005 3:06 pm

Post by martinc »

Great help.

Thank you very much.
rickdees
Posts: 14
Joined: Thu Dec 30, 2004 1:51 pm

Can you name delayed turn off scripts?

Post by rickdees »

Matt,

I've got an issue and can't come up with a solution. I want to turn off lights after they've been on for a while - for example 30 minutes. The problem I'm running into is say someone goes in and turns on a light. My script notices the light has been turned on and generates this from AppleScript.

....
turn off light in 30 minutes
...

this generates an entry in Indigo called "_delayed_action_<#>"

If the first person turns off the light, I want to be able to delete this action. Because what usually happens is another person goes in about 25 minutes later, turns on the light and then my delayed action kicks in kills the light - giving him the impression that I turned it off in only 5 minutes.

So I need a way to name these delayed actions or use some other mechanism that I'm not aware of to keep track of the numbers. Also, even if I knew the name this was given is there any way of finding that out?

thanks,

Rick Darenberg
User avatar
macpro
Posts: 780
Joined: Thu Dec 29, 2005 6:10 am
Location: Third byte on the right

Post by macpro »

You can delete delayed actions for a device using AppleScript.
Here's the info for the command:
remove delayed actions -- Removes all delayed actions, or removes delayed actions for a specific device or trigger
[for device string] -- the device name to remove all delayed acions for (ex: remove delayed actions for device "office light")
[for trigger string] -- the trigger name to remove all delayed acions for (ex: remove delayed actions for trigger "porch motion detected")
So all you have to do is add the line

Code: Select all

remove delayed actions for device light
to your script before you issue the turn off light that will set the new delay.

[edit]typo[/edit]
Last edited by macpro on Wed Oct 04, 2006 5:30 am, edited 1 time in total.
rickdees
Posts: 14
Joined: Thu Dec 30, 2004 1:51 pm

Post by rickdees »

Excellent - thanks for your help.
randysk
Posts: 48
Joined: Mon Feb 26, 2007 7:53 pm

Re: AppleScript to set an Indigo device to on and off

Post by randysk »

support wrote:Something like this should work:

Code: Select all

tell app "Indigo"
  turn on "office light"
end tell
It tried this, but I got this message:

error "Indigo 4 got an error: Can’t continue turn." number -1708 to «class turn»

Can anyone tell me what this means? Thanks.
User avatar
jay (support)
Site Admin
Posts: 18411
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: AppleScript to set an Indigo device to on and off

Post by jay (support) »

randysk wrote:
support wrote:Something like this should work:

Code: Select all

tell app "Indigo"
  turn on "office light"
end tell
It tried this, but I got this message:

error "Indigo 4 got an error: Can’t continue turn." number -1708 to «class turn»

Can anyone tell me what this means? Thanks.
Should be:

Code: Select all

tell application "IndigoServer"
    turn on "office light"
end tell
This is an ancient post from back when Indigo was at version 1.0. Have you checked out the AppleScript Dictionary for the "IndigoServer" application in this directory:

/Library/Application Support/Perceptive Automation/Indigo 4/

From Script Editor you should look at the dictionary - it'll give you all the commands and classes that Indigo provides for control.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
peppop
Posts: 104
Joined: Wed Oct 18, 2006 1:05 pm
Location: Mas
Contact:

Re: Example AppleScript to turn device on and off

Post by peppop »

How would you control I/O-Linc Controller? Lets say you wanted to turn on and off output 1.
User avatar
jay (support)
Site Admin
Posts: 18411
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Example AppleScript to turn device on and off

Post by jay (support) »

peppop wrote:How would you control I/O-Linc Controller? Lets say you wanted to turn on and off output 1.
Check this thread for information on setting outputs via AppleScript.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
miousic
Posts: 30
Joined: Sun Jun 15, 2008 1:20 pm

Re: Example AppleScript to turn device on and off

Post by miousic »

Jay, When running an applescript on a remote computer (running Indigo client), I have this message: "AppleScript support is an Indigo Pro only feature. You can upgrade from Lite to Pro for this functionality." Is there a way to run an applescript on this remote computer to control lights on the server?
User avatar
jay (support)
Site Admin
Posts: 18411
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Example AppleScript to turn device on and off

Post by jay (support) »

If you are trying to run an AppleScript on Machine A that talks to the IndigoServer process is running on Machine B, then you need to tell the script to use IndigoServer on the remote Mac, not the local one:

Code: Select all

tell application "IndigoServer" of machine "eppc://USERNAME:PASSWORD@SERVERIPADDRESSHERE"
This tells the AppleScript to tell the IndigoServer application on the remote machine to do something. Note, you need to enable remote apple events in the sharing system preferences on the IndigoServer machine. The USERNAME and PASSWORD is the user account that the IndigoServer is running on Machine B.

The error you're seeing is coming from a local IndigoServer process that's running on Machine A - it's probably unlicensed which is why you get the error.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
miousic
Posts: 30
Joined: Sun Jun 15, 2008 1:20 pm

Re: Example AppleScript to turn device on and off

Post by miousic »

Another happy customer! :)

Thanks
Locked

Return to “AppleScript Scripting”