Binding Request: Synology Surveillance Station

Hi

I find that there is an api for synology surveillance station.
Have someone any plans to create a binding for it?

/Mike

2 Likes

What would you want it to do? I use Surveillance Station on QNAP(Same app), so I could probably work on this a bit. I’m assuming you’d want triggers(or switches) on motion detection?

Yes for motion detection and also to display videostream and snapshots.

/Mike

I have now identified a need of enabling motion detected recording in surveillance station when Openhab is in Away state and disable it when at home.

/Mike

I’m interested in this too. I use synology
Surveillance station. Surveillance station keeps me from viewing the streams from my cameras, as they are already in use.

I would say enable/disable recording, stream viewing, event detections, and possibly PTZ control would be useful.

The API is accessed via HTTP and responds with JSON data.

https://www.google.com/url?sa=t&source=web&rct=j&url=https://global.download.synology.com/download/Document/DeveloperGuide/Surveillance_Station_Web_API_v2.0.pdf&ved=0ahUKEwizm6DGufnLAhVO-GMKHXJfCPcQFgggMAA&usg=AFQjCNG-rOnFm3wt3WyJ0p_f79LpdqxYgA&sig2=krmmWr7-MRG-D-tJ6I9Pgw

I could work on it in my spare time, which is very limited due to a full time job and a master’s program. I’ve never written a binding, so that makes it even harder. My lack of binding knowledge combined with my lack of time probably doesn’t make me a good candidate.

Hi,

Interested in Synology Surveillance Station too !

Regards,

–
Vincent Ferreux
Alter&Coop

I would be very interested in this as well

I would be very interested also, am happy to pay a donation also.

I happen to be available for remote working contract. Have no experience
with bounty software development though. Tend to do real freelance work
through the usual recruitment channels or my own network.

Hi Bart,

Are you referring to the Synology integration with OpenHAB?

I mean specifically a binding for Synology’s Surveilance Station. I’m already running 1.8 and experimenting with OpenHAB 2 on a spare x86 machine.

I would be also very interested in a OH2 Surveillance Station Binding :slight_smile:

NoTechi

I think Surveillance Station supports HTTP GET requests to control it’s functions from Internet. At least FHEM users reported that it works. Therefore HTTP binding should work already.
Also other direction - Station should be able to execute URL link in case of event, thus OH can be controller this way.

I’m here too to get OH2 Surveillance Station Binding ^^

Hi all,

I try successfully a script to activate the camera recording with OH2. This script uses Web API of Station Surveillance v. 8.0. It is based on documentation http://ukdl.synology.com/download/Document/DeveloperGuide/Surveillance_Station_Web_API_v2.6.pdf.
The script requires JSONPath Transformation addon (and maybe HTTP Binding ?).

val synology_surveillancestation_webapi_url = "https://<host>:<port>/webapi"
val synology_surveillancestation_login = "<your_login>"
val synology_surveillancestation_pwd = "<your_password>"
val cameraName = "cam-1"
val activationPtzPresetName = "entree"
val desactivationPtzPresetName = "disabled"

rule "Cam recording activation"
when
	Item ModeAbsence changed to ON
then
    logInfo("CamRecordingActivation", "start")
	
    sendCommand(Switch212, ON)

    // wait for ModeAbsence enables cancelled
    Thread::sleep(5000) 
	
    if (ModeAbsence.state == ON) {
	// open session (get a session id)
        var request = synology_surveillancestation_webapi_url + "/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account="+synology_surveillancestation_login+"&passwd="+synology_surveillancestation_pwd+"&session=SurveillanceStation&format=sid"
	var authenticationJsonResponse = sendHttpGetRequest(request)
        var String sessionId = transform("JSONPATH", "$.data.sid", authenticationJsonResponse)
		
	// get the cam id 
        request = synology_surveillancestation_webapi_url + "/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=9"
	var cameraListJsonResponse = sendHttpGetRequest(request)
	var String cameraId = transform("JSONPATH", "$.data.cameras[?(@.newName=='"+cameraName+"')].id", cameraListJsonResponse)
        cameraId = cameraId.replaceAll("[^\\d.-]", "")
	logDebug("CamRecordingActivation", "cameraId = " + cameraId)
	var String cameraStatus = transform("JSONPATH", "$.data.cameras[?(@.newName=='"+cameraName+"')].status", cameraListJsonResponse)
        cameraStatus = cameraStatus.replaceAll("[^\\d.-]", "")

        if (cameraStatus != "1" && cameraStatus != "5") {
              // enable camera
              request = synology_surveillancestation_webapi_url + "/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=Enable&version=9&idList=" + cameraId
	      sendHttpGetRequest(request)  
        }

        while (cameraStatus != "1" && cameraStatus != "5") {
                     Thread::sleep(3000)
                     request = synology_surveillancestation_webapi_url + "/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=9"
                     cameraListJsonResponse = sendHttpGetRequest(request)
		     cameraStatus = transform("JSONPATH", "$.data.cameras[?(@.newName=='"+cameraName+"')].status", cameraListJsonResponse)
                     cameraStatus = cameraStatus.replaceAll("[^\\d.-]", "")
        }

	if (cameraStatus == "1" || cameraStatus == "5") {
			// set the position of camera
                        request = synology_surveillancestation_webapi_url + "/entry.cgi?api=SYNO.SurveillanceStation.PTZ&method=ListPreset&version=1&cameraId="+cameraId
			var ptzPresetListJsonResponse = sendHttpGetRequest(request)
			var String activationPtzPresetId = transform("JSONPATH", "$.data.presets[?(@.name=='"+activationPtzPresetName+"')].id", ptzPresetListJsonResponse)
                        activationPtzPresetId = activationPtzPresetId.replaceAll("[^\\d.-]", "")
			sendHttpGetRequest(synology_surveillancestation_webapi_url + "/entry.cgi?api=SYNO.SurveillanceStation.PTZ&method=GoPreset&version=1&cameraId="+cameraId+"&presetId="+ activationPtzPresetId)
	} else {
			sendTelegram("x", "Error during camera activation : camera status = " + cameraStatus)
                        sendTelegram("x", "Indicating the camera status : 1 Normal, 2 Deleted, 3 Disconnected, 4 Unavailable, 5 Ready, 6 Inaccessible, 7 Disabled, 8 Unrecognized, 9 Setting, 10 Server disconnected, 11 Migrating, 12 Others, 13 Storage removed, 14 Stopping, 15 Connect hist failed, 16 Unauthorized, 17 RTSP error, 18 No video")
	}

	// close session
	sendHttpGetRequest(synology_surveillancestation_webapi_url + "/auth.cgi?api=SYNO.API.Auth&method=Logout&version=2&session=SurveillanceStation&_sid=" + sessionId)
    }
	
    logInfo("CamRecordingActivation", "end")	
end

Bye

1 Like

I would be also very interested in a OH2 Surveillance Station Binding

1 Like

Are there any news on this topic?
I´ve tried to use the stream urls from the cam or from the surveillance station in a webview or video item but that doesn´t seem to work.

I support this request too. Aim is to e.g. get a live stream or snapshot initiated from a rule. I’ve been struggling with ONVIF but never managed to make it work. A Syno binding can be used towards all supported cameras.

I got it done!
I have set the substream of the camera to mjpeg.
On my Sitemap I use the following line:
Video url=“http://[username]:[password]@192.168.178.[XXX]/Streaming/channels/102/httppreview” encoding=“mjpeg” label="IP-Cam 01"
This works with an Trendnet Cam with the Hikvision Firmware. I think nearly all other cams have such an url where you can fetch the stream.
The 102 defines the substream of the camera.

Sounds great.
I will have a look.
Thanks!