/synologysurveillancestation

Synology Surveillancestation Binding

Primary LanguageJava

Synology Surveillance Station Binding

This binding connects openHAB with your surveillance cameras running on Synology© DiskStation using Synology Surveillance Station API. This binding should work with any DiskStation capable of running Surveillance Station as well as with any supported camera.

Table of contents


Disclaimer

This binding is currently under development. Your help and testing would be greatly appreciated but there is no stability or functionality warranty.

Installation and upgrade

For an installation the latest release should be copied into the /addons folder of your openHAB installation. For an upgrade the existing file should be overwritten. On major or structural changes existing things might have to be deleted and recreated, existing channels might be kept. For further information please read release notes of a corresponding release.

Supported Things

Currently following Things are supported:

  • Bridge Thing representing the Synology DiskStation / Surveillance Station
  • One or many Things for supported Cameras

Discovery

If your openHAB installation is in the same network as your Synology DiskStation, the discovery will automatically find your Surveillance Station. You can now add its Bridge Thing, which will first be OFFLINE. You should now configure the Bridge and enter your Surveillance Station credentials. For security reasons it's always a better practice to create a separate user for this. After entering correct credentials and updating the Bridge, automatic discovery for cameras will start. If successful, your cameras will be found and can be added without further configuration.

Configuration

Following options can be set for the Bridge:

  • Access protocol of the DiskStation
  • Host/IP of the DiskStation
  • Port of the DiskStation
  • User name for the DiskStation / Surveillance Station
  • Password for the DiskStation / Surveillance Station
  • Refresh rate for DiskStation events (Home Mode)
  • (advanced) Enable support for self-signed / invalid SSL certificates (binding or openHAB restart required on change)

Following options can be set for the Camera:

  • Snapshot refresh rate
  • Refresh rate for all other Camera events and dynamic channels
  • Refresh rate for motion detection parameter (defaults to 0 = no autorefresh)

Channels

Currently following Channels are supported on the Bridge:

  • Home mode SWITCH
  • External event trigger NUMBER (1 to 10, write-only)
  • Current session ID (SID) STRING

Currently following Channels are supported on the Camera:

  • Common channels:
    • Snapshot IMAGE
    • Camera recording SWITCH
    • Enable camera SWITCH
  • URIs:
    • Snapshot static URI STRING
    • Snapshot dynamic URI (refreshes with event refresh rate) STRING
    • Snapshot static live feed URI (rtsp) STRING
    • Snapshot static live feed URI (mjpeg over http) STRING
  • PTZ (Pan/Tilt/Zoom) for PTZ cameras only:
    • Zoom IN/OUT
    • Move UP/DOWN/LEFT/RIGHT/HOME
    • Continuous Move/Zoom with START_<COMMAND> and STOP_<COMMAND> (e.g. START_IN)
    • Move to preset
    • Run patrol
  • Event channels:
    • Motion event SWITCH (read-only)
    • Alarm event SWITCH (read-only)
    • Manual event SWITCH (read-only)
    • Continuous recording event SWITCH (read-only)
    • External event SWITCH (read-only)
    • Action rule event SWITCH (read-only)
  • Motion detection channels (if available):
    • Motion detection source STRING (-1:disable, 0:by camera, 1:by Surveillance Station)
    • Motion detection sensitivity NUMBER (1 to 99)
    • Motion detection threshold NUMBER (1 to 99)
    • Motion detection object size NUMBER (1 to 99)
    • Motion detection percentage NUMBER (1 to 99)
    • Ignore short-lived motion for NUMBER (0 to 10) seconds

File based configuration

.things

Bridge synologysurveillancestation:station:diskstation "DiskStation" @ "ServerRoom" [ protocol="http", host="192.168.0.1", port="5000", username="my username", password="my password", acceptSsl="false" ] {
Thing camera CameraID "Camera 1" @ "Outside" [ refreshRateEvents=5, refreshRateSnapshot=10, refreshRateMdParam=120, snapshotStreamId=1 ]
}

or for a self-signed SSL certificate:

Bridge synologysurveillancestation:station:diskstation "DiskStation" @ "ServerRoom" [ protocol="https", host="192.168.0.1", port="5001", username="my username", password="my password", acceptSsl="true" ] {
Thing camera CameraID "Camera 1" @ "Outside" [ refreshRateEvents=5, refreshRateSnapshot=10, refreshRateMdParam=120, snapshotStreamId=1 ]
}

Here the CameraID is a numeric ID of your surveillance camera in Surveillance Station (e.g. 1) and snapshot stream ID is the ID of the preferred stream in Surveillance Station (e.g. 1 for 'Stream 1')

.items

Switch Surveillance_HomeMode "Home Mode" {channel="synologysurveillancestation:station:diskstation:homemode"}
Number:Dimensionless Surveillance_Event_Trigger "External event trigger" {channel="synologysurveillancestation:station:diskstation:eventtrigger"}
String Surveillance_SID "Current SID" {channel="synologysurveillancestation:station:diskstation:sid"}

Image Surveillance_Snapshot "Snapshot" {channel="synologysurveillancestation:camera:diskstation:1:common#snapshot"}

String Surveillance_Snapshot_Uri_Dynamic "Dynamic snapshot URI" {channel="synologysurveillancestation:camera:diskstation:1:common#snapshot-uri-dynamic"}
String Surveillance_Snapshot_Uri_Static "Static snapshot URI" {channel="synologysurveillancestation:camera:diskstation:1:common#snapshot-uri-static"}
String Surveillance_Snapshot_Live_Uri_Rtsp "Live feed URI (rtsp)" {channel="synologysurveillancestation:camera:diskstation:1:common#live-uri-rtsp"}
String Surveillance_Snapshot_Live_Uri_Mjpeg_Http "Live feed URI (mjpeg over http)" {channel="synologysurveillancestation:camera:diskstation:1:common#live-uri-mjpeg-http"}

Switch Surveillance_Recording "Camera recording" {channel="synologysurveillancestation:camera:diskstation:1:common#record"}
Switch Surveillance_Enabled "Camera enabled" {channel="synologysurveillancestation:camera:diskstation:1:common#enable"}

Switch Surveillance_Event_Motion "Camera motion event" {channel="synologysurveillancestation:camera:diskstation:1:event#motion"}
Switch Surveillance_Event_Alarm "Camera alarm event" {channel="synologysurveillancestation:camera:diskstation:1:event#alarm"}
Switch Surveillance_Event_Manual "Camera manual event" {channel="synologysurveillancestation:camera:diskstation:1:event#manual"}
Switch Surveillance_Event_Continuous "Camera continuous recording event" {channel="synologysurveillancestation:camera:diskstation:1:event#continuous"}
Switch Surveillance_Event_External "Camera external event" {channel="synologysurveillancestation:camera:diskstation:1:event#external"}
Switch Surveillance_Event_ActionRule "Camera action rule event" {channel="synologysurveillancestation:camera:diskstation:1:event#actionrule"}

String Surveillance_Zooming "Camera zooming" {channel="synologysurveillancestation:camera:diskstation:1:ptz#zoom"}
String Surveillance_Moving "Camera moving" {channel="synologysurveillancestation:camera:diskstation:1:ptz#move"}
String Surveillance_Presets "Camera moving to preset" {channel="synologysurveillancestation:camera:diskstation:1:ptz#movepreset"}
String Surveillance_Patrols "Camera run patrol" {channel="synologysurveillancestation:camera:diskstation:1:ptz#runpatrol"}

String Surveillance_MD_Source "Motion detection source" {channel="synologysurveillancestation:camera:diskstation:1:md-param#md-param-source"}
Number:Dimensionless Surveillance_MD_Sensitivity "Motion detection sensitivity" {channel="synologysurveillancestation:camera:diskstation:1:md-param#md-param-sensitivity"}
Number:Dimensionless Surveillance_MD_Threshold "Motion detection threshold" {channel="synologysurveillancestation:camera:diskstation:1:md-param#md-param-threshold"}
Number:Dimensionless Surveillance_MD_Objectsize "Motion detection objectsize" {channel="synologysurveillancestation:camera:diskstation:1:md-param#md-param-objectsize"}
Number:Dimensionless Surveillance_MD_Percentage "Motion detection percentage" {channel="synologysurveillancestation:camera:diskstation:1:md-param#md-param-percentage"}
Number:Dimensionless Surveillance_MD_Shortlive "Ignore short-lived motion" {channel="synologysurveillancestation:camera:diskstation:1:md-param#md-param-shortlive"}

Here :1 is yet again the numeric ID of your surveillance camera from a previous step.

.sitemap

Switch item=Surveillance_Zooming mappings=[IN="IN", OUT="OUT"]

// Some cameras like Reolink do not support simple stepping
Switch item=Surveillance_ContinuousZoomingIn mappings=[START_IN="Start ZoomIn", STOP_IN="Stop ZoomIn"]
Switch item=Surveillance_ContinuousZoomingOut mappings=[START_OUT="Start ZoomOut", STOP_OUT="Stop ZoomOut"]

Switch item=Surveillance_Moving mappings=[UP="UP", DOWN="DOWN", LEFT="LEFT", RIGHT="RIGHT"]
 
Selection item=Surveillance_Presets label="Surveillance_Presets Selection" 
Switch item=Surveillance_Presets label="Surveillance_Presets Mapping" mappings=[preset1="Preset 1",preset2="Preset 2"]

Image item=Surveillance_Snapshot_Uri_Static url="[%s]" refresh=5000
Video item=Surveillance_Snapshot_Live_Uri_Mjpeg_Http url="[%s]" encoding="mjpeg"

Transformation

Existing URIs can also be transformed using JS transformation to build similar URIs. Most requests can be extended or constructed manually using SID (session ID) for authentication by adding &_sid=your-current-SID to the query string. Please refer to Synology Surveillance Station API documentation for more details.

Example: SID-based stream URI (over http).

.items

String Surveillance_Snapshot_Live_Uri_Static "SID-based URI" {channel="synologysurveillancestation:camera:diskstation:1:common#snapshot-uri-static"[profile="transform:JS", function="liveuri.js"]}

transform/liveuri.js

(function(i) {
    return i.replace("entry.cgi", "SurveillanceStation/videoStreaming.cgi").replace(".Camera", ".VideoStream").replace("version=8", "version=1").replace("GetSnapshot", "Stream&format=mjpeg")
})(input)

Please note, Javascript Transformation add-on must be installed for the transformation to work properly.

Support

If you encounter critical issues with this binding, please consider to:

  • create an issue on GitHub
  • search community forum for answers already given
  • or make a new post there, if nothing was found

In any case please provide some information about your problem:

  • openHAB and binding version
  • error description and steps to retrace if applicable
  • any related [WARN]/[ERROR] from openhab.log
  • whether it's the binding, bridge, camera or channel related issue

For the sake of documentation please use English language.