-
Notifications
You must be signed in to change notification settings - Fork 0
/
IndigoControl.applescript
93 lines (79 loc) · 3.2 KB
/
IndigoControl.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
-------------------------------------------------
-- Internal functions for dispatching commands to Indigo's python scripting engine:
on _getIphPath()
set iph to "/usr/local/indigo/indigo-host"
set iph72 to "/Library/Application Support/Perceptive Automation/Indigo 7.2/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
set iph7 to "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
set iph6 to "/Library/Application Support/Perceptive Automation/Indigo 6/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
set iph5 to "/Library/Application Support/Perceptive Automation/Indigo 5/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
tell application "System Events"
if exists file iph then
return iph
else if exists file iph72 then
return iph72
else if exists file iph7 then
return iph7
else if exists file iph6 then
return iph6
else if exists file iph5 then
return iph5
else
error "Indigo Server not installed"
end if
end tell
end _getIphPath
on _executeIphCommand(command)
set iphPath to _getIphPath()
do shell script quoted form of iphPath & " -e " & quoted form of command
end _executeIphCommand
-------------------------------------------------
-- Helper functions for executing an action group (by name or ID):
on executeActionGroup_byName(groupName)
_executeIphCommand("indigo.actionGroup.execute(\"" & groupName & "\")")
end executeActionGroup_byName
on executeActionGroup_byID(groupID)
_executeIphCommand("indigo.actionGroup.execute(" & groupID & ")")
end executeActionGroup_byID
-------------------------------------------------
-- Helper functions for on/off control of a devices (by name or ID):
on turnOn_byName(devName)
_executeIphCommand("indigo.device.turnOn(\"" & devName & "\")")
end turnOn_byName
on turnOff_byName(devName)
_executeIphCommand("indigo.device.turnOff(\"" & devName & "\")")
end turnOff_byName
on toggle_byName(devName)
_executeIphCommand("indigo.device.toggle(\"" & devName & "\")")
end toggle_byName
on turnOn_byID(devID)
_executeIphCommand("indigo.device.turnOn(" & devID & ")")
end turnOn_byID
on turnOff_byID(devID)
_executeIphCommand("indigo.device.turnOff(" & devID & ")")
end turnOff_byID
on toggle_byID(devID)
_executeIphCommand("indigo.device.toggle(" & devID & ")")
end toggle_byID
-------------------------------------------------
-- Helper functions for setting a variable value (by name or ID):
on updateVariable_byName(varName, newValue)
_executeIphCommand("indigo.variable.updateValue(\"" & varName & "\", \"" & newValue & "\")")
end updateVariable_byName
on updateVariable_byID(varID, newValue)
_executeIphCommand("indigo.variable.updateValue(" & varID & ", \"" & newValue & "\")")
end updateVariable_byID
-------------------------------------------------
-- Examples (uncomment or replace with your calls):
--executeActionGroup_byName("cooking scene")
--executeActionGroup_byID("1969538881")
--
--turnOn_byName("office lamp")
--turnOff_byName("office lamp")
--toggle_byName("office lamp")
--
--turnOn_byID("1091151457")
--turnOff_byID("1091151457")
--toggle_byID("1091151457")
--
--updateVariable_byName("houseMode", "someNewValue1")
--updateVariable_byID("1389001099", "someNewValue2")