Close

Location-Based Dis/Arming

Learn how to turn an Android phone into an IP camera security system with Sighthound, download automation scripts & more.

Moderator: Staff

no avatar
audiblelbink
 
Posts: 2
Joined: Mon Mar 30, 2015 12:45 pm

Location-Based Dis/Arming

by audiblelbink » Mon Mar 30, 2015 2:27 pm

Hey all. I recently came from an application called Witness by Orbicule. It suited my need for motion-tracking, recording and alerting. One of my favorite features was the "don't think about it" arming and disarming of the system using the iOS app's location based features. This was sorely missed in Sighthound so I started poking around.

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.

no avatar
joelegg
 
Posts: 39
Joined: Wed Feb 04, 2015 6:58 am

Re: Location-Based Dis/Arming

by joelegg » Wed Apr 15, 2015 1:36 am

thanks for posting. This is a much needed feature OOTB in sighthound.

no avatar
303
 
Posts: 44
Joined: Sat May 03, 2014 4:02 am
Location: Palo Alto, CA

Re: Location-Based Dis/Arming

by 303 » Tue Sep 08, 2015 3:57 am

one note for anyone reading this and wanting to play around, you'll need to find your own auth token (where he says TOKEN_WITHHELD above) by using mitm or charles proxy.

User avatar
ryan
 
Posts: 1015
Joined: Wed Aug 25, 2010 2:52 pm
Location: Palo Alto, California

Re: Location-Based Dis/Arming

by ryan » Thu Sep 10, 2015 4:05 pm

It's standard HTTP auth so you could simply include the user/pass in the URL and remove the auth header. The following is equivalent (other headers were pretty and spec compliant, but optional as well).

Code: Select all
curl 'http://USER:PASS@IP:PORT/xmlrpc/' --data-binary $'<?xml version=\'1.0\'?><methodCall><methodName>enableCamera</methodName><params><param><value><string>CAM_NAME</string></value></param><param><value><boolean>1</boolean></value></param></params></methodCall>'
Learn more about Sighthound Video in our support pages - Reference Guide | All Articles
Are you a developer? Check out our cloud APIs - Demo | Docs

no avatar
mrmisi
 
Posts: 12
Joined: Tue Apr 22, 2014 9:55 am

Re: Location-Based Dis/Arming

by mrmisi » Wed Sep 16, 2015 3:31 am

I've did the same thing but on android device.
If you looking for it, you can use Tasker app with SSH plugin (you must have a server SSH running on the machine where Sighthound is installed)

no avatar
keenest
 
Posts: 2
Joined: Mon Jun 27, 2016 10:09 pm

Re: Location-Based Dis/Arming

by keenest » Tue Jun 28, 2016 9:46 am

I realize this is an old thread but the functionality of arming and disarming cameras automatically based on presence or other trigger like SmartThings is still not available natively, correct? What if you took this curl command and run it from the maker channel in IFTTT? I might give this a shot. Thoughts? Seriously Sighthound, just add this to your IFTTT channel!!!

no avatar
keenest
 
Posts: 2
Joined: Mon Jun 27, 2016 10:09 pm

Re: Location-Based Dis/Arming

by keenest » Tue Jun 28, 2016 10:37 am

Getting "301 - moved permanently" when using that call. Anyone know of the new call so I do not have to sniff it with a proxy?

no avatar
dscdsc
 
Posts: 1
Joined: Sat Feb 04, 2017 12:05 am

Re: Location-Based Dis/Arming

by dscdsc » Sat Feb 04, 2017 12:11 am

I know this is old but I have also been looking for a way to do location based arming/disarming for a while too.

My hack/workaround is by using IP cameras connected to a remotely controlled outlet.
In my case I have an iDevices switch plugged into the wall socket and the power supply of the IP camera controlled by it.
I have my HomeKit automation set to turn off the outlet when I arrive at home and to turn on when I leave.

By cutting the power to the IP camera sighthound gets no feed from it. After the IP camera is powered on, sighthound usually connects within 1-2 mins.

I already have several devices in my HomeKit setup that turn on/off based on my location so I just added this switch to it.

I'm sure this set up could be replicated using other smart home hubs like smart things.


Return to Hacker's Corner