This How-To will show you how to perform common tasks in AppleScript. These lines will run as is if they are run from an embedded AppleScript. If you want to run them from outside Indigo (i.e. Script Editor), then enclose them in a tell application block like this:
tell application "IndigoServer" turn on "Office Lamp" end tell
turn on "Office Lamp" turn on "Office Lamp" for 60 -- leaves the light on for one minute (60 seconds) then turns it back off turn on "Office Lamp" in 60 -- turns the light on after delaying one minute (60 seconds) turn on "Office Lamp" in 60 for 60 -- combines the above two -- the previous options work as well with "turn off" and "toggle"
-- Note: all brighten/dim numbers are 0-100 (0 being off and 100 being all the way on) brighten "Office Lamp" to 85 -- sets the brightness to 85 regardless of previous setting brighten "Office Lamp" by 25 -- brightens the lamp by 25 from it's current setting brighten "Office Lamp" by 25 in 5 -- delays the brighten command by 5 seconds dim "Office Lamp" to 25 -- sets the brightness to 25 regardless of previous setting dim "Office Lamp" by 25 -- dims the lamp by 25 from it's current setting dim "Office Lamp" by 25 in 5 -- delays the dim command by 5 seconds
-- Each of the below enable statements has a corresponding disable command enable time date action "Test T/D Action" -- enables a time/date action named "Test T/D Action" enable time date action "Test T/D Action" for 60*60 -- same as above, but leaves the t/d action enabled only for 1 hour (60 seconds * 60 minutes) enable time date action "Test T/D Action" in 60 -- enables a time/date action named "Test T/D Action" but delays one minute (60 seconds) first enable time date action "Test T/D Action" in 60 for 60*60 -- combines the above two -- Each of the below enable statements has a corresponding disable command enable trigger action "Test Trigger Action" -- enables a trigger action named "Test Trigger Action" enable trigger action "Test Trigger Action" for 60*60 -- same as above, but leaves the t/d action enabled only for 1 hour (60 seconds * 60 minutes) enable trigger action "Test Trigger Action" in 60 -- enables a trigger action named "Test Trigger Action" but delays one minute (60 seconds) first enable trigger action "Test Trigger Action" in 60 for 60*60 -- combines the above two
execute group "Test Action Group" -- execute the group execute group "Test Action Group" in 60 -- delay the group execution by one minute (60 seconds)
execute script file "MyDisk:Path:to:the:script:file.scpt" execute script POSIX file "/Path/to/the/script/file.scpt"
-- Getting the temperature and humidity from a thermostat is a little complex -- because the values of those properties are actually lists - it's possible to get -- multiple temperatures and humidity readings with the right equipment (with external -- sensors, etc.) set tempList to temperatures of device "First Floor" -- tempList is now an AppleScript list - for a standard thermostat it will be something like {74} -- with just one item. To get each item, you need to refer to it by number: set theTemp to item 1 of tempList -- After this line executes, theTemp will be equal to 74. -- Humidity values work exactly the same way. If you're using an IO device that has multiple inputs and outputs, -- they will also be presented as lists.
set hvac mode of device "First Floor" to heatCoolOn -- operation based on the heat and cool setpoints set hvac mode of device "First Floor" to runProgramAuto -- automatic operation of the Auto program that you create on the thermostat set heat setpoint of device "First Floor" to 72 -- used when heatOn or heatCoolOn are set as hvac mode set cool setpoint of device "First Floor" to 78 -- used when coolOn or heatCoolOn are set as hvac mode set fan mode of device "First Floor" to fanAlwaysOn -- keeps the fan running all the time - fanAutoOn is the other option
set sprinkler zone of device "Sprinkler" to 0 -- turns the sprinkler off set sprinkler zone of device "Sprinkler" to 1 -- turns on zone one which will run for the max duration
-- Create a variable named "Test_Variable" make new variable with properties {name:"Test_Variable", value:"Some Value Here"} -- Get the value of a variable named "Test_Variable" into an AppleScript variable named theVarValue set theVarValue to value of variable "Test_Variable" -- Set the value of a variable named "Test_Variable" to "Hello World!" set value of variable "Test_Variable" to "Hello World!"
-- The following line log "This is a typical log entry" -- results in " Script This is a typical log entry" being inserted into the log -- to change "Script" to something more useful, use the following line log "This is a typical log entry" using type "MyTestScript -- results in " MyTestScript This is a typical log entry" being inserted into the log
-- This one will remove any delayed actions associated with the device named "Office Lamp" remove delayed actions for device "Office Lamp" -- This will remove any delayed actions from a trigger named "My Test Trigger" -- (this can be either a time/date action or a trigger action) remove delayed actions for trigger "My Test Trigger" -- This will remove all delayed actions remove delayed actions
-- NOTE: for this to work correctly, you MUST have the with transaction block INSIDE a -- tell application "IndigoServer" even if this is being run embedded. tell app "IndigoServer" with transaction transaction suppress logging -- Anything after this line before the end transaction line will NOT be logged turn on "Office Sconces" turn off "Office LampLinc" set brightness of device "Office Overhead" to 35 end transaction log "Office scene created" using type "Office Script" end tell
-- NOTE: for this to work correctly, you MUST have the with transaction block INSIDE a -- tell application "IndigoServer" even if this is being run embedded. tell application "IndigoServer" with transaction transaction suppress state change sending -- every state change command after the above suppress verb -- that is inside this "with transaction" block will not send out any -- interface commands set brightness of device "Virtual Volume Controller" to 15 turn on "Virtual Attic Fan" end transaction end tell
if ((value of variable "houseMode" = "night") and (value of variable "houseStatus" = "vacation")) then -- do whatever you need to do here end if