Using `mitmproxy` I discovered the app would make calls to my home server with the following information. I've rewritten it as a curl command for convenience:
- Code: Select all
curl 'http://HOME_IP:8848/xmlrpc/' \
-H 'Authorization: TOKEN_WITHELD' \
-H 'Accept: text/xml' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Accept-Language: en-us' \
-H 'User-Agent: SightHound/1.0.454 CFNetwork/711.1.12 Darwin/14.0.0' \
-H 'Content-Type: text/xml' \
-H 'Connection: keep-alive' \
--data-binary $'<?xml version=\'1.0\'?><methodCall><methodName>enableCamera</methodName><params><param><value><string>Living Room</string></value></param><param><value><boolean>1</boolean></value></param></params></methodCall>'
Running this from a command line turned on my Living Room camera. Replacing the Boolean value with a 0 turned it off.
So I now have half of the solution. Now, I wanted something to run these commands based on my location. I opted for IFTTT's Dropbox channel. I installed Dropbox on the same machine where Sighthound is installed. The IFTTT apps now have device specific triggers, which is great. I created a rule; when I leave a certain geo-fenced area, a file called 'log' should be appended with a timestamp.
At this point I had a working command that will enable and disable my camera and an action that was occurring on the same machine where Sighthound is installed. All that was needed was something that monitored this file and fired the command when it changed.
For this, I used OS X built-in launchutils.
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.YOUR_NAME.alarm</string>
<key>Program</key>
<string>/YOUR/PATH/TO/arm.sh</string>
<key>WatchPaths</key>
<array>
<string>/Users/YOUR_USER/Dropbox/IFTTT/Sighthound/arm/</string>
</array>
<key>RunAtLoad</key>
<false/>
</dict>
</plist>
I created this file at '/usr/local/bin' and called 'arm.sh' which contains the curl command from above, preceded by the line:
- Code: Select all
#!/bin/bash
Make sure to make it executable with:
- Code: Select all
chmod u+x YOUR/PATH/TO/arm.sh
This file path is the "Program" property in the xml. I then pointed the 'WatchPaths' property to "/Users/admin/Dropbox/IFTTT/Sighthound/arm/", the folder that houses the file Dropbox is writing to.
Save this file to ~/Library/LaunchDaemons/com.YOUR_NAME.alarm.arm.plist and run:
- Code: Select all
launchutil load ~/Library/LaunchDaemons/com.yourname.alarm.arm.plist
You're done. When you leave a geofenced area of your choosing, your cameras will arm. Repeat the procedure for disarming while changing the pertinent values.
Sidenote, this is also handy with IFTTT's newer "Do Button" app. It's really just an app that lets you fire actions. It's pretty much the same, except the IF is always "you pressed a button" and the THAT is the trigger. It's a neat way to manually arm and disarm your cameras.
I'm not the best technical writer, so please, ask questions or provide edit suggestions.