Turn On/Off Sighthound Security Cam Rules via IFTTT

We just moved, and in my last apartment, we lived on the second floor and I had my Foscam security camera [~$60] (which is controlled by the Basic version of Sighthound Video [$60]) trained on the only stairwell, which only captured people arriving or leaving. However in our new house, none of the doors are in locations where the camera only captures egress & ingress events.  There’s a bathroom right next to one door and the other is between the living room and the stairs.  Thus, anywhere I set up a security camera is bound to capture the regular activity inside the house. So I first experimented with setting the rules to make the cameras active during certain hours on the weekdays, which turned out pretty annoying, because my wife’s schedule is random.  What I needed was a way to turn the camera rules off & on based on when we arrive & leave the house, the same way I use WeMo to control the window unit air conditioners and the air filter.

I discovered that Sighthound has an IFTTT channel and an iOS app, but their IFTTT channel only has triggers upon motion detection and no “actions” that could be run using Life360 (the app I use to control the AC & filter – e.g. turn on when the first person arrives and off when the last leaves or vice versa).  So I emailed Sighthound to see if they had any tips for enabling and disabling camera rules.  They pointed me to one of their forums called Hacker’s Corner, where I got pointed in the right direction.

Here’s how to enable your security camera (rule) when the last person in your family leaves the house and disable the camera when the first person in your family arrives.

These are the things you will need:

  1. A Mac computer that is always running
  2. A Foscam camera or other IP camera compatible with Sighthound Video [~$60]
  3. At least the Basic version of Sighthound Video [$60] (The free version of Sighthound Video doesn’t have the necessary remote access settings.)
  4. The Life360 app [free] on all family member’s phone, in the same “circle”, and with your home recorded as a “place” in the circle.
  5. Dropbox [free] installed on the Mac computer from #1
  6. An IFTTT account with the Life360 and Dropbox channels [free]
  7. A command line utility called curl (which you may need to install by opening /Applications/Utilities/Terminal.app and running `xcode-select –install`) [free]

I will forgo describing how to setup your computer, camera, and all the basic apps/accounts, as they’re all fairly straightforward.  I will say, just as some general tips, it’s a good idea to have Sighthound Video save clips in which is has detected motion, in your dropbox, so if your computer gets stolen, you’ll still have footage of the perpetrator.  It’s also good to have alerts configure to notify you upon motion detection.  Furthermore, it’s good to have the IFTTT app notify you when the rules run, at least for awhile, so you can be sure that the system is working.

Let’s start from the point where you already have Sighthound Video running and your cameras configured for it.  I will walk you through enabling and disabling the rule for a single camera.  There should be a default rule under the Sighthound Video “Cameras” tab in the bottom left pane.  If you don’t already have a 24 hour surveillance rule configured in Sighthound Video for, select the camera you want to rule applied to in the top right corner of the window and create one in the rules pane on the bottom left.  Don’t worry about it being set to run 24 hours a day.  We will be enabling and disabling the rule based on your location and setting this rule to 24 hours every day simply ensures that when we leave, the camera will be running.  I’ve named mine “MudroomSecurity”.  If you have it set for 24 hours every day, you’ll see the blue text “Every day – 24 hours” in the middle:

Screen Shot 2017-06-15 at 11.52.10 AM.png

Note that the rule is enabled when the checkbox on the right side is checked.  If all rules for a camera are disabled, Sighthound video will no longer record video or issue alerts.

The camera itself may still run and be accessed via its own interface (e.g. typing its DHCP address into a browser on your local network) but, unless explicitly setup for remote access or if your network is open, is not accessible via the outside world.

Note, the precise name of the rule in Sighthound Video is important for what we’re going to do later, so instead of relying on the default auto-generated rule name, let’s create a custom name (without spaces- and case sensitive).  Click on the little black downward arrow next to the existing rule and select “Edit rule…”.  In the following window, click the “Customize name” link depicted in this example:

customname.png

Type in the name you want, copy & paste it somewhere so you can be sure to use the same exact name later, then click “OK”.  Click “OK” on the Rule Editor window.

Next, we need to start up a Sighthound Video server that we will be using to communicate with the Sighthound Video app that’s always running in the background (whether the Sighthound Video GUI is running or not).

  1. Select Sighthound Video->Preferences.
  2. Check “Enable remote access” (this will only be on your internal network – DO NOT check the “Open this port in my router” option – it’s unnecessary and is a security risk).
  3. Choose a user ID and password.
  4. Make a note of the remote access port number (8848 by default) or change it if desired.
  5. Click “Apply”.
  6. Click “OK”.

If you did the above correctly, it should look like this:

shremotesettings.png

Note that “External address” is “Not available” and the local address is 127.0.0.1 (we’ll be using this later).  At this point, you can quit Sighthound Video if you want.  You can run it later just to ensure that your automation is correctly enabling/disabling the rules.

Next, let’s create the 2 folders in Dropbox that will be used to trigger the enabling/disabling of the rule we just created in Sighthound Video.  Since I already use folder actions triggered via IFTTT for a number of other things, I keep them organized in a separate folder.  For the purposes of this tutorial, let’s create the following folders:

  • ~/Dropbox/IFTTT/FolderActions/SecCamsEnable/
  • ~/Dropbox/IFTTT/FolderActions/SecCamsDisable/

Now, we need to create an IFTTT applet that will create files inside these folders when the last member of your family leaves and the first member of your family arrives.  So we’re going to create 2 applets.  Let’s create the one that disables the rule first:

  1. Login to your account on IFTTT.com.
  2. Click “My Applets” at the top of the IFTTT home page.
  3. Click the “New Applet” button.
  4. Click the blue “this” link.
  5. Select your “Life360” channel.
  6. Select the “First family member arrives at a specific place” trigger.
  7. Select the “place” you created for your home in the Life360 app.
  8. Click the “Create Trigger” button.
  9. Click the blue “that” link.
  10. Select your Dropbox channel.
  11. Select the “Create a text file” action.
  12. Enter a title as “{{PersonName}} arrived {{PlaceName}} first at {{ArrivedAt}}” to ensure each file is named differently. (Skip the Content section – not important.)
  13. Enter the disabled folder path under “Dropbox folder path” as we specified above: “IFTTT/FolderActions/SecCamsDisable/”.
  14. Click the “Create Action” button.
  15. Click the “Finish” Button.
  16. If you want to edit the Applet name, use the gear icon on the top right.

Repeat this procedure for enabling cams, choosing “Last family…” in step 6, using “{{PersonName}} left {{PlaceName}} last at {{ArrivedAt}}” instead of “{{PersonName}} arrived {{PlaceName}} first at {{ArrivedAt}}” in step 12, and specifying folder “IFTTT/FolderActions/SecCamsEnable/” in step 13, and you’ll end up with applets that look like this:

endisablecams.png

The last, and most important step requires Automator.app in your /Applications folder.  Run Automator.  We’re going to create 2 folder actions: one to enable, and one to disable the rule you created in Sighthound Video.

  1. If Automator doesn’t ask when you start it, select File->New to create a new workflow, select “Folder Action”, and click the “Choose” button: fa.png
  2. Drag the “Run Shell Script” action from the middle pane to the workspace on the right: wnxq7g
  3. Click the “Choose folder” menu and select “Other…” and find your “~/Dropbox/IFTTT/FolderActions/SecCamsDisable” folder
  4. Click the “Shell” menu and select “/bin/tcsh” (my preferred shell – and what I wrote this example in)
  5. Select “Pass input” “as arguments” (though we’re not really going to use this – just preventing open input handles)
  6. Replace all the text in the text box below with the following code (click to get a version you can copy/paste: disablepb.png
  7. Enter the info you entered into Sighthound Video earlier in place of “YOUR_RULE_NAME”, “YOUR_USERNAME”, and “YOUR_PASSWORD”.  You might also change the port number from 8848 in case you edited it.
  8. Save your Automator workflow and name it something like “DisableSecCamsOnAdd”
  9. Quit Automator
  10. Navigate in the Finder to “~/Dropbox/IFTTT/FolderActions/”
  11. Right-click the “SecCamsDisable” folder and select “Services->Folder Actions Setup…”
  12. In the drop-down sheet, select your workflow from step 8 (e.g. “DisableSecCamsOnAdd”).  If the sheet does not come down and the workflow isn’t already present in the right pane, click the “+” button under the right pane and select your workflow there.
  13. Repeat this procedure for enabling the security cams, selecting “SecCamsEnable” in step 3, additionally changing the value of ONOROFF from 0 to 1 in step 7, saving as “EnableSecCamsOnAdd” in step 8, clicking “SecCamsEnable” in step 11, and selecting “EnableSecCamsOnAdd” in step 12.

Now, you should be able to enable and disable your security camera rule when your family comes and goes.  To test to make sure it’s working, drag any file into “~/Dropbox/IFTTT/FolderActions/SecCamsDisable/” and run Sighthound Video to ensure that the rule has been disabled.  Likewise, drag any file into “~/Dropbox/IFTTT/FolderActions/SecCamsEnable/” to see that the rule is turned back on.  Note that the Sighthound Video interface must be refreshed between workflow runs.  When the workflow runs, you will briefly see a turning gear on the right side of your system menu bar.  Once it has disappeared, simple click the “Search” tab and back to the “Cameras” tab to see that the enabled rule checkbox has been ticked or unticked.  Or you can quit and restart Sighthound Video to see the change.  Then the rule is disabled and you have no other enabled rules, the preview of the camera will blank out with a message about no active rules.

You can run the code that was pasted into automator on the command line in the Terminal, though you’ll likely have the run the command “tcsh” since Apple’s default shell is bash.  Then just paste in your edited code to see if you can enable & disable Sighthound Video rules from the command line.

If you have multiple cameras, there are different options, but the easiest thing to do would be to paste the code into automator twice and change the YOUR_RULE_NAME value to the name of the rule for the other camera (rule names must be unique and each camera must have its own rules).  The other “setenv” variables in the code do not have to be pasted a second time if they are not changing for the second camera.

I’d be interested to see if this has helped anyone, so please leave comments.  If you run into any issues in the future, let me know.

Advertisements

2 thoughts on “Turn On/Off Sighthound Security Cam Rules via IFTTT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s