I have some cameras that are always recording but that have certain rules that are only enabled when I plan to be away, which trigger notifications. For some time I've have wanted to find a way to update away mode in Indigo that can also enable certain rules in Sighthound Video. Thanks to some work by others I've found a way to do exactly this in Indigo.
The groundwork can be found in this Sighthound Video forum post: Automation: Enabling cameras from the command-line
In order to setup Indigo to control rules for a camera you will need to know the full name of the rule that you want to control. You'll need to have remote access enabled and also be comfortable with including your username and password for Sighthound unencrypted in text files (shell scripts).
I'm using Indigo 6.1.4 running on Mac OS X 10.10.5. You'll need cURL but I found that it was included in my version of OS X.
In this post I'll be referring to a Kitchen Camera with a rule named "Vacation Away in Kitchen".
Outside of Indigo, in a path of your choosing, you'll be creating four files. Two of these are XML files and two are shell scripts. There is one of each file for turning the rule off and one for turning it on.
The first thing to do is to create the XML files.
<?xml version="1.0"?><methodCall>
<methodName>remoteEnableRule</methodName>
<params>
<param>
<value>
<string>Vacation Away in Kitchen</string>
</value>
</param>
<param>
<value>
<boolean>1</boolean>
</value>
</param>
</params>
</methodCall>
The only two values that you would change for your own needs should be bolded in the example above.
Next just create a copy of the first file and then change the boolean value from 1 to 0. A value of 1 will enable a rule and a value of 0 will disable a rule. It may be helpful to include ON or OFF in the filename of the appropriate file.
The next set of files will serve to run cURL and deliver the XML files to Sighthound. For this method they should have a ".sh" extension.
Here's the code from the script that I used to turn the rule on:
#!/bin/bash
curl --user username:password --header "Content-Type: application/xml" -X POST -d@/Users/username/Documents/Kitchen-Vacation-Away-ON.xml 'http://localhost:9000/xmlrpc/'
Note that "username:password" should be replaced with the username and password that you have configured for remote access in Sighthound. The path after "-d@" is for one of the XML files for toggling the rule. The use of "localhost" assumes that Sighthound is on the same system as Indigo. If you changed the default port make sure to change "9000" to match.
Note that both shell scripts need to be made executable, which can be done from the terminal in the same directory as the shell scripts. For example:
chmod +x away-kitchen-on.sh
At this point I recommend testing the scripts from the terminal to ensure that they will execute properly. From this point on everything else was done in Indigo.
In Indigo I first created a variable for storing the cameras state (camKitchenON), with false representing OFF and true representing ON.
Then I created an Action Group for each state of the camera (one for ON and one for OFF). In each Action Group I added only one action, which runs the corresponding shell script to turn the rule on or off.
Next, I created a Virtual Device named "Kitchen Camera". The Action Groups that I previously created are then used for the virtual devices "ON Group" and "OFF Group". In the configuration I enabled "Supports Status" and then chose camKitchenON as the "Status Variable".
Once finished, I can now toggle the rule in Sighthound video.
Note that when executed the checkbox in the Sighthound GUI for the rule may not update until you click away from the camera and then back to it, though you will see the camera feed start if it was not enabled by another rule.
Also note that in this method I am not checking the status of the rule itself; simply sending a command. However, cURL will receive an XML response so I imagine that verifying the state is not a difficult task for someone with more scripting knowledge and time.
I have multiple cameras, all of which are setup so that I can toggle a rule from Indigo. I am only toggling rules from Indigo; not actually stopping or starting cameras in Sighthound though that is also certainly possible and can even be done with this information and what is provided in the Sighthound Video forum link included above.
Originally I had my away mode set as a Virtual Device that changed the state of multiple camera Virtual Devices but that did not work; perhaps I simply missed something minor or there is an issue with having one Virtual Device directly modify another one. To work around this I simply had the away mode Virtual Device execute the camera action groups instead of the camera Virtual Devices themselves though each camera still has its own Virtual Device so I can toggle the rules independent of a specific mode.
I hope others find this useful. I regret that I am unable to write a plugin to automate most of this (and add more features) but I have yet to find time even to simply learn Python.