SATI download

Posted on
Tue Aug 18, 2015 8:33 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

SATI download

https://www.dropbox.com/s/yfncdnbluet5haq/SATI-0-3-3.zip?dl=1
fSimple Applescript to Indigo (SATI) interface .

this should help with the situation when you have applescript error messages "application not running"

steps to install:
1. download zip file,
2. install SATI plugin,
3. select the frequency of interaction between this plugin and applescript in config (i.e. how often will the file be checked). 1 second is probably ok.
The plugin will create a directory SATI in ~/documents


how to use:
check out the included applescript file for an example how to use it...

you can
- get values of variables or device/states
- set value of a variable
- execute an action group
- execute any valid python command within indigo

use the following to execute in applescript:
set cmd to "\"getVariable;:;:;varName\" "
set cmd to "\"getDeviceState;:;:;devName;:;:;stateName\" "
set cmd to "\"setVariable;:;:;varName;:;:;value\" "
set cmd to "\"exeAction;:;:;877534\" "
set cmd to " \"getvariable;:;:;EnergyMonth2\" " -- this is the same as the next one in my installation EnergyMonth2 has indigo id = 1048490539
set cmd to " \"getvariable;:;:;1048490539\" "
set cmd to " \"EXECCMD;:;:;indigo.server.log('hallo') \" " -- will print "hallo" in the indigo logfile, you could put any command here, use wisely
set cmd to " \"EXECCMD;:;:;indigo.device.turnOn('GameRoomCeilingLights')\" " -- turns on the light in my game room

== the ";:;:;" is used as a delimiter between the commands and variable names etc. it is unlikely that ;:;:; is used in any variable name etc.
== devName and varName and actName can be strings or IDs
== upper and lowercase for commands can be used as you like

how does it work:

the plugin "listens" on 10 channels for commands -- we use files (~/documents/SATI/toIndigo-n) to get the message into the plugin they should contain e.g. : exeAction;:;:;877534
It gets the command, deletes the file, parses it, executes the requested command and writes the result to
~/documents/SATI/toAS-n where n is the channel number and it will contain e.g. ok or 123.5 ... or error missing arg ...
Each channel is independent of each other. If you use this interface in several applescript programs each needs to use its own channel or if you are doing things in parallel also use different channels.

the results are
- value/ result returned from indigo (get variable value)
- "error xxx" in case something went wrong
- "ok" if you e.g. set a variable, as there is no value to return

the example applescript has 2 subroutines:
on toIndigo(channel, cmd) and
on fromIndigo(channel)

they are called from the applescript example to send the command to indigo and get the result back.
instead of applescript file management I just took unix echo, ls, cat etc to write check for files and read files.
if you like you can change that yourself to pure applescript.



next functions could be:
switch device on
switch device off
dim device

and
subscribe to changes of a variable or device/state.


Again, this should be a SIMPLE interface, easy to use, but it will never supply all available functions of indigo.

Karl

Posted on
Wed Aug 19, 2015 9:24 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SATI download

https://www.dropbox.com/s/xoyeeufirsgzdh1/SATI-v-0-2-2.zip?dl=0 v 0-2-2 [EDIT fixed V number ]

added:

1. Subscriptions to variables and device/states
2. turn on / off devices
3. dimm devices
4. turn on / off digital outputs (i.e. garage door openers)
5. some better log file print outs with more info


here the examples how to define commands in applescript:

devName and varName and actName can be strings or IDs
naturally you need to replace the text with your device names and value. you can use variables or straight forward text in the set cmd to examples (as it is done here):

the general structure is (here for 2 parameters .. can be 1 ..3):
set sep to ";:;:;"
set cmd to "\"command"&sep&"parameter1"&sep&"parameter2\" "
toIndigo(channelNumber, cmd)
will create a file fromAS-n with contents:
command;:;:;parameter1;:;:;parameter2


where command and parameters are one of these (upper / lower case for COMMAND is not important, but might be important for variableName of values):
getVariable + variableName/id
setVariable + variableName + value

getDeviceState + deviceName/id + stateName

exeAction + actionName/id

turnDeviceOn + deviceName/id
turnDeviceOff + deviceName/id

setBinaryOutputOn + deviceName/id + index of output pin
setBinaryOutputOff + deviceName/id + index of output pin

setBrightness + deviceName/id + value (0-100)

and for subscriptions:
subscribeDeviceState + deviceName/id +stateName + channel
subscribeDeviceStateDelete + deviceName/id +stateName
subscribeVariable + variableName/id + channel
subscribeVariableDelete + variableName/id


and the special one to execute a straight forward python command as you specify::
execCmd +pythonCode

Code: Select all
set sep to ";:;:;"

--set vvvv to "window"
--set cmd to "\"getVariable" &sep& & vvv &"\" "

--set cmd to "\"getDeviceState" &sep& "devNamexxx" &sep& "stateNamexxx\" "

--set cmd to "\"setVariable" &sep& "varName" &sep& "33\" "

--set cmd to "\"exeAction" &sep& "877534\" "

--set cmd to " \"getvariable" &sep& "EnergyMonth2\"   "

-- turn device on:
-- set cmd to " \"execCmd" & sep & "indigo.device.turnOn('GameRoomCeilingLights')\" "  --- with python code executed
--or
--set cmd to " \"turnDeviceOn" &sep& "GameRoomCeilingLights\"   "


--turn device off
-- set cmd to " \"execCmd" & sep & "indigo.device.turnOff('GameRoomCeilingLights')\" "
--or
--set cmd to " \"turnDeviceOff" &sep& "GameRoomCeilingLights\"   "

-- set brightness to 55% for device GameRoomCeilingLights
--set cmd to " \"setBrightness" &sep& "GameRoomCeilingLights" &sep& "55\"   "

-- set BinaryOutput ON  for device garageDoor , output 0
--set cmd to " \"setBinaryOutputON" &sep& "garageDoor" &sep&"0\"   "

-- set BinaryOutput off  for device garageDoor
--set cmd to " \"setBinaryOutputOff" &sep& "garageDoor" &sep&"0\"   "


-- subscribe to changes in Variable to state temperature using channel 5
--set cmd to " \"subscribeVariable" &sep& "temperature" &sep& "5\"   "
-- delete subscription
--set cmd to " \"subscribeVariableDelete" &sep& "temperature\"   "

-- subscribe to changes in DeviceState to device / state  thermostat / temperature using channel 6
--set cmd to " \"subscribeDeviceState" &sep& "thermostat" &sep& "temperature" &sep&" 6\"   "
-- delete subscription
--set cmd to " \"subscribeDeviceStateDelete" &sep& "thermostat" &sep& "temperature\"   "

--set cmd to " \"execCmd" &sep& "indigo.server.log('hallo') \" "  -- will print "hallo" in the logfile, you could put any command here, use wisely



Posted on
Wed Aug 19, 2015 2:59 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SATI download

Simple Applescript To Indigo Interface (SATI)
https://www.dropbox.com/s/cn5919ca8a7zbx6/SATI-v-0-3-1.zip?dl=0 version 0-3-1
This is everything I had planned to do. If no more requests (and errors) its done.


This plugin should help with the situation when you have applescript error messages "application not running" It gives an option to send commands and receive values from indigo in Applescript. You can naturally also use the RESTful interface to do this. But it was fun to do.

steps to install:
1. download zip file,
2. install SATI plugin,
3. select the frequency of interaction between this plugin and applescript in config (i.e. how often will the file be checked). 1 second is probably ok.
The plugin will create a directory SATI in ~/documents


how to use:
check out the included applescript file for an example how to use it...

you can
- get values of variables or device/states
- set value of a variable
- execute an action group
- set temperature / fan of thermostats
- set devices on/off and set brightness
- subscribe to changes of devices/states and variables in indigo and receive them in applescript
- execute any valid python command within indigo




fixed:
set brightness was not working properly

added
thermostat
setCoolpoint
setHeatpoint
setFanModeOn
setFanModeOff


Code: Select all
here the examples how to define commands in applescript:

devName and varName and actName can be strings or IDs
naturally you need to replace the text with your device names and value. you can use variables or straight forward text in the set cmd to examples (as it is done here):

the general structure is (here for 2 parameters .. can be 1 ..3):
set sep to ";:;:;"
set cmd to "\"command"&sep&"parameter1"&sep&"parameter2\" "
toIndigo(channelNumber, cmd)
will create a file fromAS-n with contents:
command;:;:;parameter1;:;:;parameter2


where command and parameters are one of these (upper / lower case for COMMAND is not important, but might be important for variableName of values):
getVariable + variableName/id
setVariable + variableName + value

getDeviceState + deviceName/id + stateName

exeAction + actionName/id

turnDeviceOn + deviceName/id
turnDeviceOff + deviceName/id

setBinaryOutputOn + deviceName/id + index of output pin
setBinaryOutputOff + deviceName/id + index of output pin

setBrightness + deviceName/id + value (0-100)

setCoolSetpoint + deviceName/id + temperature
setHeatSetpoint + deviceName/id + temperature
setFanModeOn + deviceName/id
setFanModeAuto + deviceName/id




and for subscriptions:
subscribeDeviceState + deviceName/id +stateName + channel
subscribeDeviceStateDelete + deviceName/id +stateName
subscribeVariable + variableName/id + channel
subscribeVariableDelete + variableName/id


and the special one to execute a straight forward python command as you specify::
execCmd +pythonCode



Code: Select all
global pathX
set myuserid to "karlwachs"
set pathX to "/Users/" & myuserid & "/Documents/SATI/"


on toIndigo(channel, cmd)
   set cmd to "echo " & cmd
   do shell script cmd & " > " & pathX & "fromAS-" & channel as string
end toIndigo

on fromIndigo(channel, repeats)
   repeat repeats times
      set cmd to "ls " & pathX & "toAS-" & channel as string
      set retString to ""
      try
         set retString to do shell script cmd
      end try
      if retString is not equal to "" then
         set cmd to "cat " & pathX & "toAS-" & channel as string
         set indigoMSG to do shell script cmd
         set cmd to "rm " & pathX & "toAS-" & channel as string
         do shell script cmd
         return indigoMSG
      end if
      delay 0.5
   end repeat
   return " timeout waiting for indigo"
end fromIndigo

set sep to ";:;:;"

-- devName and varName and actName  can be strings or IDs

--set cmd to "\"getVariable" &sep& "varName\" "

--set cmd to "\"getDeviceState" &sep& "devName" &sep& "stateName\" "

--set cmd to "\"setVariable" &sep& "varName" &sep& "value\" "

--set cmd to "\"exeAction" &sep& "877534\" "

--set cmd to " \"getvariable" &sep& "EnergyMonth2\"   "


--set cmd to " \"execCmd" &sep& "indigo.server.log('hallo') \" "  -- will print "hallo" in the logfile, you could put any command here, use wisely

-- turn device on:
-- set cmd to " \"execCmd" & sep & "indigo.device.turnOff('GameRoomCeilingLights')\" "
--or
--set cmd to " \"turnDeviceOn" &sep& "GameRoomCeilingLights\"   "


--turn device off
-- set cmd to " \"execCmd" & sep & "indigo.device.turnOn('GameRoomCeilingLights')\" "
--or
--set cmd to " \"turnDeviceOff" &sep& "GameRoomCeilingLights\"   "

-- set brightness to 55% for device GameRoomCeilingLights
--set cmd to " \"setBrightness" &sep& "GameRoomCeilingLights" &sep& "55\"   "

-- set BinaryOutput ON  for device garageDoor
--set cmd to " \"setBinaryOutputON" &sep& "garageDoor\"   "

-- set BinaryOutput off  for device garageDoor
--set cmd to " \"setBinaryOutputOff" &sep& "garageDoor\"   "


-- subscribe to changes in Variable to variable temperature
--set cmd to " \"subscribeVariable" &sep& "temperature\"   "
-- delete subscription
--set cmd to " \"subscribeVariableDelete" &sep& "temperature" &sep& channelNo&\"   "

-- subscribe to changes in DeviceState to device / state  thermostat / temperature
--set cmd to " \"subscribeDeviceState" &sep& "thermostat" &sep& "temperature" &sep& channelNo&"\"   "
-- delete subscription
--set cmd to " \"subscribeDeviceStateDelete" &sep& "thermostat" &sep& "temperature\"   "




--some real examples:
--this will turn the lights in my game room on for 5 seconds:
set cmd to " \"execCmd" & sep & "indigo.device.turnOn('GameRoomCeilingLights')\" "
toIndigo(1, cmd)
set retString to fromIndigo(1, 30)
delay 5
set cmd to " \"execCmd" & sep & "indigo.device.turnOff('GameRoomCeilingLights')\" "
toIndigo(1, cmd)
set retString to fromIndigo(1, 30)
delay 2

-- this will set brightness to 55% for 5 seconds and then off again
set cmd to " \"setBrightness" & sep & "GameRoomCeilingLights" & sep & "55\"   "
toIndigo(1, cmd)
set retString to fromIndigo(1, 30)
delay 5
set cmd to " \"turnDeviceOff" & sep & "GameRoomCeilingLights\"   "
toIndigo(1, cmd)
set retString to fromIndigo(1, 30)


delay 0.2

--this will subscribe to any changes in device id 1500077079 state = Touch_string
set cmd to " \"SUBSCRIBEDEVICESTATE" & sep & "1500077079" & sep & "Touch_string" & sep & "2\" "
toIndigo(1, cmd)
set retString to fromIndigo(1, 30)
delay 1

-- this will continuously check if device/state has changed adn get the value into retString
repeat 10 times
   delay 0.5
   set retString to fromIndigo(1, 2)
end repeat

delay 0.2


-- and now we diable the subscription, but indigo will still call the oplugin, we will just ignore it.
set cmd to " \"SUBSCRIBEDEVICESTATEDelete" & sep & "1500077079" & sep & "Touch_string\" "
toIndigo(1, cmd)

delay 0.2

-- set thermostat gameRoom fan on and back to auto after 10 secs (using id or name)
set cmd to " \"setFanModeOn" & sep & "1332829462\" "
toIndigo(1, cmd)
delay 10
set cmd to " \"setFanModeAuto" & sep & "ThermostatGameRoom\" "
toIndigo(1, cmd)
delay 1
-- set thermostat gameRoom cool temp to 71 and to 74 after 10 (using id or name)
set cmd to " \"setCoolSetpoint" & sep & "1332829462" & sep & "71\" " -- if the thermostat has some limits set it will ignore values outside the range
toIndigo(1, cmd)
delay 10
set cmd to " \"setCoolSetpoint" & sep & "ThermostatGameRoom" & sep & "74\" "
toIndigo(1, cmd)


Posted on
Thu Apr 14, 2016 1:21 pm
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: SATI download

If this is running on a Mac remote from the Indigo server, will it allow the remote Mac to receive commands from Indigo like

Code: Select all
open iTunes on machine  "eppc://192.168.99.255"
?

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Thu Apr 14, 2016 2:01 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SATI download

the plugin runs on the mac indigo server.
it reads and writes a local file on THAT box.

So it you want to communicate with it the applescript has to write / read files on THAT box.

Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest