Binding Request: Synology Surveillance Station

Found the solution, finally. The binding worked all the time, but since this version of OpenHAB, if you use a module file which is not part of the distribution you just add it into $OPENHAB-HOME/addons without adding it to the binding line of services/addons.cfg. I removed the entry from services/addons.cfg and the ‘failed installing’ message disappeared.

Hi all,
the binding works in general for me. However, two out of my four cameras are constantly offline.
My things configuration is as follows:

Bridge synologysurveillancestation:station:diskstation "DiskStation" @ "Büro" 
    [ protocol="http", host="192.168.178.80", port="5000", username="<deleted>", password="<deleted>" ] {
Thing camera 1 "Kamera 1" @ "Outside 1" [ refresh-rate-events=5, refresh-rate-snapshot=10, refresh-rate-md-param=120, snapshot-stream-id=1 ]
Thing camera 2 "Kamera 2" @ "Outside 2" [ refresh-rate-events=5, refresh-rate-snapshot=10, refresh-rate-md-param=120, snapshot-stream-id=1 ]
Thing camera 3 "Kamera 3" @ "Outside 3" [ refresh-rate-events=5, refresh-rate-snapshot=10, refresh-rate-md-param=120, snapshot-stream-id=1 ]
Thing camera 4 "Kamera 4" @ "Outside 4" [ refresh-rate-events=5, refresh-rate-snapshot=10, refresh-rate-md-param=120, snapshot-stream-id=1 ]
}

When restarting the binding I get the following messages

2020-01-25 21:05:00.249 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:4' changed from OFFLINE (GONE) to UNINITIALIZED
2020-01-25 21:05:00.276 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:4' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-01-25 21:05:00.280 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:1' changed from OFFLINE (GONE) to UNINITIALIZED
2020-01-25 21:05:00.304 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:1' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-01-25 21:05:00.309 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:2' changed from ONLINE to UNINITIALIZED
2020-01-25 21:05:05.338 [WARN ] [core.thing.internal.ThingManagerImpl] - Disposing handler for thing 'synologysurveillancestation:camera:diskstation:2' takes more than 5000ms.
2020-01-25 21:05:05.358 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:2' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-01-25 21:05:05.364 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:3' changed from ONLINE to UNINITIALIZED
2020-01-25 21:05:10.403 [WARN ] [core.thing.internal.ThingManagerImpl] - Disposing handler for thing 'synologysurveillancestation:camera:diskstation:3' takes more than 5000ms.
2020-01-25 21:05:10.421 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:3' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-01-25 21:05:10.427 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:station:diskstation' changed from ONLINE to UNINITIALIZED
2020-01-25 21:05:11.504 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:station:diskstation' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-01-25 21:15:14.498 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler SynoBridgeHandler of thing synologysurveillancestation:station:diskstation tried updating channel sid although the handler was already disposed.
2020-01-25 21:15:14.590 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:station:diskstation' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2020-01-25 21:15:14.647 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:station:diskstation' changed from INITIALIZING to ONLINE
2020-01-25 21:15:14.713 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:1' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2020-01-25 21:15:15.417 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:1' changed from INITIALIZING to OFFLINE (GONE)
2020-01-25 21:15:15.450 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static1 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=4Sbs5ZXYiNASg1840QEN120003&camStm=1&cameraId=2 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=1
2020-01-25 21:15:15.455 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:2' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2020-01-25 21:15:16.389 [me.event.ThingUpdatedEvent] - Thing 'synologysurveillancestation:camera:diskstation:2' has been updated.
2020-01-25 21:15:16.397 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:2' changed from INITIALIZING to ONLINE
2020-01-25 21:15:16.493 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:4' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2020-01-25 21:15:16.506 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static4 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=4Sbs5ZXYiNASg1840QEN120003&camStm=1&cameraId=4 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2
2020-01-25 21:15:16.511 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static2 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=4Sbs5ZXYiNASg1840QEN120003&camStm=1&cameraId=2 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2
2020-01-25 21:15:16.514 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static1 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=1 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2
2020-01-25 21:15:16.518 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static3 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=4Sbs5ZXYiNASg1840QEN120003&camStm=1&cameraId=3 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2
2020-01-25 21:15:16.581 [home.event.InboxAddedEvent] - Discovery Result with UID 'synologysurveillancestation:camera:diskstation:5' has been added.
2020-01-25 21:15:16.580 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'synologysurveillancestation:camera:diskstation:5' to inbox.
2020-01-25 21:15:16.834 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:4' changed from INITIALIZING to OFFLINE (GONE)
2020-01-25 21:15:16.853 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:3' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2020-01-25 21:15:16.855 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static4 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=4
2020-01-25 21:15:17.705 [me.event.ThingUpdatedEvent] - Thing 'synologysurveillancestation:camera:diskstation:3' has been updated.
2020-01-25 21:15:17.709 [hingStatusInfoChangedEvent] - 'synologysurveillancestation:camera:diskstation:3' changed from INITIALIZING to ONLINE
2020-01-25 21:15:17.745 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static3 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=3
2020-01-25 21:15:18.109 [me.event.ThingUpdatedEvent] - Thing 'synologysurveillancestation:camera:diskstation:1' has been updated.
2020-01-25 21:15:23.161 [me.event.ThingUpdatedEvent] - Thing 'synologysurveillancestation:camera:diskstation:2' has been updated.
2020-01-25 21:15:23.811 [me.event.ThingUpdatedEvent] - Thing 'synologysurveillancestation:camera:diskstation:2' has been updated.
2020-01-25 21:15:23.953 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static4 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=4 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2
2020-01-25 21:15:23.955 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static3 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=3 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2
2020-01-25 21:15:28.252 [me.event.ThingUpdatedEvent] - Thing 'synologysurveillancestation:camera:diskstation:3' has been updated.
2020-01-25 21:15:28.785 [me.event.ThingUpdatedEvent] - Thing 'synologysurveillancestation:camera:diskstation:3' has been updated.
2020-01-25 21:15:28.801 [vent.ItemStateChangedEvent] - Surveillance_Snapshot_Uri_Static3 changed from http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=2 to http://192.168.178.80:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&version=8&method=GetSnapshot&_sid=1zYkXJ6celj1Q1840QEN120003&camStm=1&cameraId=3

Probably it is a stupid mistake somewhere.
Thanks for any hint.

Hi Thomas,

please try to increase snapshot timeouts and see whether it helps.

BR Pav

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