Tips & Tricks

SecuritySpy Surveillance integrated with Home Assistant

Home Assistant has a lot of built-in support for Cameras and Surveillance systems. But the program I am using is not supported out of the box, so this post will explain how to integrate SecuritySpy from Ben Software in to Home Assistant.

In order to get started make sure that SecuritySpy is installed and that you have enabled the build-in Webserver in SecuritySpy. This Webserver exposes the API that we will be using to talk to SecuritySpy from Home Assistant.

On my system I show both live images from the Cameras setup in SecuritySpy, but I also have created a couple of switches so that I can arm or disarm the Cameras from Home Assistant.
To see a full list of supported functions, look at this post on the Bensoftware Website

Camera Definition

To setup a SecuritySpy Camera in Home Assistant write the following in your configuration file:

camera:
- platform: mjpeg
  mjpeg_url: http://YOUR_IPADDRESS:8000/++video?cameraNum=<camera>&quality=<quality>&req_fps=<fps>
  still_image_url: http://YOUR_IPADDRESS:8000/++image?cameraNum=<camera>&quality=<quality>
  username: !secret securitySpy_user
  password: !secret securitySpy_pass
  name: CAMERA NAME

<camera> is the number of the camera, as displayed in the Camera Info window
<width> is the width of the image in pixels
<height> is the height of the image in pixels
<quality> is the compression quality in the range 1 to 100
<fps> is the FPS of video that SecuritySpy will attempt to send
<username> if you have enabled username and password on the webserver put this here
<password> if you have enabled username and password on the webserver put this here

Repeat this for each Camera you have defined in SecuritySpy

Arm and Disarm Switch

When I lock the door in my home, I arm all the outdoor cameras. You can send a command to SecuritySpy to both Arm and Disarm the cameras.
The Switch will automatically pull its On state from SecuritySpy, so if you set the Armed state in SecuritySpy it will also be reflected in Home Assistant.
Open your Home Assistant configuration file and add the following:

switch:
- platform: command_line
  switches:
    name_of_your_switch:
      command_on: '/usr/bin/curl -k "http://<username>:<password>@YOUR_IPADDRESS:8000/++ssControlMotionCapture?cameraNum=<camera>&arm=1"'
      command_off: '/usr/bin/curl -k "http://<username>:<password>@YOUR_IPADDRESS:8000/++ssControlMotionCapture?cameraNum=<camera>&arm=0"'
      command_state: '/usr/bin/curl -k --silent "http://<username>:<password>@YOUR_IPADDRESS:8000/++cameramodes?cameraNum=0" | grep -oP "(?<=M:).*"'
      value_template: '{{ value == "ARMED" }}'

<camera> is the number of the camera, as displayed in the Camera Info window
<username> if you have enabled username and password on the webserver put this here (Else remove text including @)
<password> if you have enabled username and password on the webserver put this here (Else remove text including @)

 

Tagged , , ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.