Binding Request: Synology Surveillance Station

Hi @Pavion ,
thanks for the ultra quick reply. To be honest, I do not know how to increase the snapshot timeouts.
Anyway, by digging deeper I discovered that the generated http requests to my Synology DiskStation do not work for the offline cameras, i.e., the following request works well for cameraId=2 but results in an error code instead of returning a picture (129.168.178.80 being the IP address of my Synology):

http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=HlW4dGqYJElOM1840QEN120003&camStm=2&cameraId=4

So it seems that my Synology does not grant access for 2 cameras. Did not found out yet how to change this…

Sure, getting snapshot will fail if a camera is disabled / offline… But what is an offline camera?

With camera timeout I’ve meant the refresh-rate-snapshot parameter, which you may try to increase. Too small (fast) refresh rates cause higher cpu load and may produce some issues on older/slower systems.

You can also enable debug mode for this binding in Karaf with:
log:set DEBUG org.openhab.binding.synologysurveillancestation
there you can see additional info and SSS responses. You can PM me some more log output then.

Hello together!

For those of you keen to explore the new and shiny openHAB 3.0, there is a new compatible pre-release of this binding available at the project’s page. Please feel free to share your feedback :sunglasses:

BR Pav

Problem solved: Synology gave for the missing cameras an error code 401 (“Parameter invalid”). As the only parameter difference was the camera number, I tried consecutive numbers 5 and 6, which worked! Probably when I installed and deinstalled cameras, freed up numbers did not get reassinged.

Hi,
can the binding caputure an image of the camera, which will be sent to my mobile via pushover like
describes here?
BR Bernd

Hi @Bernd_R
This binding offer an IMAGE item and an URI of this image, both can probably be used as attachment. Search this forum for more information, for example:

Note: if this is your only usage for this binding, consider using a php solution instead. With a simple script you can connect to Surveillance Station and download current snapshot into a file, which could then be sent as attachment.

BR Pav

1 Like

I’ve been using it for front door notifications with pictures for a couple years now (since this binding came about).

rule "Front Door Camera Motion Snapshot Notification"
when
	Item fdCamMotion changed from OFF to ON
then
	val fdCamURL = frontDoorCamDSnap.historicState(now.minusSeconds(5)).state.toFullString
	val file = now.toString.replaceAll("[:\\/ \\+]+", "_") +".jpg"
	val fdCamSnapTmp = "/etc/openhab2/snap/" + file
	var String curl_result = executeCommandLine("curl -m 10 -o " + fdCamSnapTmp + " " + fdCamURL, 5000)
	sendPushoverMessage(pushoverBuilder("FrontDoor").withAttachment(fdCamSnapTmp))
end
1 Like

Thanks Pavion and waspie,
I use the binding and the following code:

rule "SavePictureAndSendNotification"
when
	Item F_Tuerklingel changed to ON
then
	createTimer(now.plusSeconds(2)) [|
		logDebug("Imagerule", "Save Image")
		var String CameraImage 	= SE_CamImage.state.toFullString 						//Convert image item to base64 encoded string
		val String Image64 		= CameraImage.split(",").get(1)							//Slice the string up to the delimiter ","
		var byte[] data 		= DatatypeConverter.parseBase64Binary(Image64)
		try {
			var OutputStream os;
			val time 		= new DateTime().millisOfDay().getMillis()
			var File f 		= new File("/etc/openhab2/html/" + triggeringItem.name + "_" + time + ".jpg")
			os.write(data);
			os.close();
			
			sendPushoverMessage(pushoverBuilder("Doorbell").withAttachment(f.getAbsolutePath()))
			
		}catch (IOException e) {
			e.printStackTrace();
		}
	]
end

So far the binding works great, RackStation RS217 running at 27% load.
For the time being I stay with the binding and I am going to expand
the setup in future.

Hi @Pavion,
another small glitch which I discovered.
When I try to change the “Event refresh rate” for “DiskStation” in Paper UI (Configuration > Things > DiskStation > Edit) I get at first a “Thing updated” message, followed by a “ERROR: 409 - Conflict”. The value did not change.
Any ideas?

BR Thomas

Hi @tkropf
Looks like you’ve defined your Thing in an .things file so you can only change this parameter there.
BR Pav

Hi @Pavion,

thanks for the quick answer. Indeed, I am using a .things file. This probably is the reason.
Looking in your documentation on GitHub I do find a hint for the parameter (" Following options can be set for the Bridge : […] Refresh rate for DiskStation events (Home Mode)").
Unfortunately, the parameter name is missing in your .things template:

Bridge synologysurveillancestation:station:diskstation "DiskStation" @ "ServerRoom" [ protocol="http", host="192.168.0.1", port="5000", username="my username", password="my password" ] {
Thing camera CameraID "Camera 1" @ "Outside" [ refresh-rate-events=5, refresh-rate-snapshot=10, refresh-rate-md-param=120, snapshot-stream-id=1 ]
}

Can you reveal the secret :wink:
BR Thomas

Oh… you’re right, I’ve somehow forgot to mention it…
It’s actually the same as for the Camera:

refresh-rate-events=2

@Pavion,
many thanks. Mystery solved, the parameter change using “refresh-rate-events” in the .things file worked after an OpenHAB restart.

Dear all,
I have a small issue with the binding.
I have been able to install easily and I have my snapshots visible on my sitemaps.
However the stream (Video) are not showing up.
I have tested to take the url in the string and copy/paste it in both chrome and VLC, it works fine.

I have a foscam C2 and ycam bullet that are showing up nicely in my synology.
I am wandering if there should be something to declare / do on either synology side or camera side.

I am kind of stuck and not really knowing which direction to take. I would be happy to share any log / config parameters needed.

BR and nice job

Jonathan

Hi @jjacqmot

Sitemaps seem to have an issue with quotes which are part of live URI.
You can try this workaround:

items/camera.items

Channel definition with transformation.
Note: Add-ons -> Transformations -> Javascript Transformation must be installed.

String Surveillance_Snapshot_Live_Uri_Mjpeg_Http "Live feed URI (mjpeg over http)" {channel="synologysurveillancestation:camera:myid:1:common#live-uri-mjpeg-http"[profile="transform:JS", function="livefeed.js"]} 

transform/livefeed.js

This small script will parse input and remove all quotes ".

(function(i) {
    return i.replaceAll("\"", "")
})(input)

sitemaps/my.sitemap

Note using encoding="mjpeg" here:

sitemap My label="My" {
    Frame label="My" {
        Video item=Surveillance_Snapshot_Live_Uri_Mjpeg_Http url="[%s]" encoding="mjpeg"
    }
}

BR Pav

Hello Pav,

Thanks you solved the issue !

I have one more question concerning the messages around ID 280 in this thread. I have similar issues with the motion detection. Surveillance station is not taking care of the motion detection, the camera does. In the timeline, I see that SS is recording continuously for a certain amount of days and record (blue line) some events detected (supposedly by motion detection from camera). However, nothing triggers the channel in openhab.

I have created a Rule of Action but it does not seem to be working. Any clue on this topic ? I would like to avoid recording 2 times the same events (through motion detection standard and rules of action)

Thanks again

Best regards
Jonathan

I found out that the home mode was activated… I tested this mode a while ago and never payed attention afterwards.
Obviously this mode has its own calendar that was defined for continuous recording. This was taking over the standard calendar / schedule…Problem solved

1 Like

Hi,
first of many thanks for the binding :slight_smile:

I got following error when I activate or deactivate the “Camera enabled” switch in a rule:

[ERROR] [ternal.webapi.request.SynoApiRequest] - RESPONSE: {“error”:{“code”:401,“errors”:{“param1”:"",“param2”:""}},“success”:false}

The error is thrown in both cases OFF and ON

command in my rule to disable the camera completly:
InstarTerCommonEnable.sendCommand(OFF)
and the other command to activate the camera:
InstarTerCommonEnable.sendCommand(ON)

Since the rule is doing what it is intended for (disabling/enabling the camera) I could just ignore this error but if there is a way to not trigger this error it would be even better :slight_smile:

NoTechi

Hi @NoTechi,
Sorry, but I can’t reproduce your error. If you get this response, binding shouldn’t work at all. If it still works, there is a bug somewhere. Please check your credentials/user and whether you have but one copy of this binding running using
bundle:list | grep Syno

Please note that you can just disable all errors with following command:
log:set FATAL org.openhab.binding.synologysurveillancestation

If you encounter further issues, please provide some more information regarding your setup.

BR Pav

Hi @Pavion,

there is only one instance running:

203 x Active x 80 x 2.5.0.201911151402 x openHAB Add-ons :: Bundles :: Synology Surveillance Station Bin

My setup:
Openhab 2.5.4 running in a docker on a Synology NAS (using different ports for openhab then the standard)
org.openhab.binding.synologysurveillancestation-2.5.0-SNAPSHOT.jar in my addon folder

The bridge configuration/credentials should be ok since I get access to my cams. However I looked up the credentials again and saw it is configured to http on port 5000. Shouldn’t it be 9900 (HTTP) or 9901 (HTTPS)?

NoTechi

Update:
After a openhab restart I got:

[WARN ] [.core.thing.binding.BaseThingHandler] - Handler SynoBridgeHandler of thing synologysurveillancestation:station:15b1mhn934300 tried updating channel sid although the handler was already disposed.

Could this be related to the Error?