Binding Request: Synology Surveillance Station

To answer your questions:
I am using SurvStation as detection source in the event detection panel
I am in continuous recording h24 (limit 10gb)
I see events in blue in the timeline app, in the live screen the little logo in the top right become red when there is movement… but no trigger to Camera motion event switch :frowning:
Other swtiches like Home mode or Camera action rule event are working fine!

Try to create an action rule: “start action rule recording” on “Motion detected”. Perhaps you’ll see “Action rule event” Switch triggered then.
If you’ve already checked the API and it sends no corresponding event, I don’t know where to begin :confused:

hi, yes with the action rule on motion detected it works… just the motion detection itself not :frowning:

Isn’t it enough for your purpose?

As far as I know, all events we’re speaking about are not pure events (e.g. Hey! Motion detected!) but instead secondary recording events (Hey! I'm starting recording _because of_ motion detected!). If a motion is detected but no recording is started (or it’s already active), no recording event might be triggered.

One observation I have is my synology software was updated last night automatically and the binding changed from communication with the IPv4 address to a link-local IPv6, which was not working. When I changed it back to IPv4, it worked fine again. Not sure how/why the binding changed to IPv6 after the software update and why it broke.

That might be a known issue related to automatic discovery. mDNS discovery seem to discover DS twice: as IPv4 and as IPv6, which may cause warnings or errors. If you have any breaking issues, please try using text file configuration.

I installed the binding and added (manually) the thing: my DS213 and two cameras. So far this worked and the DS213 is shown as ONLINE both in PaperUI and in the console.
As soon as I add an item - I am trying with

Switch Surveillance_Homemode “Home Mode” {channel=“synologysurveillancestation:station:DS213:homemode”}

in PaperUI the thing status of the DS213 changes to “Status: OFFLINE - COMMUNICATION_ERROR Thread HomeMode”.
On the console, DS213 still shows as “ONLINE”, bu Surveillance_Homemode is NULL.
Any idea what might be the reason?
If I try http://dsm.caliaro.net/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=6&account=&passwd=&ession=SurveillanceStation&format=sid the result is {“data”:{“is_portal_port”:false,“sid”:“OO0ZBHQkuuQSoD2L5N02809”},“success”:true}
The same happens if I eg add the item “Snapshot” of one of my cameras: the camera then becomes “OFFLINE (COMMUNICATION_ERROR): Thread Snapshot”.

You have a rather old system so I can imagine two issues:

  1. Your API is outdated

Please check our DSM and SS versions, latest are DSM 6.2 and Surveillance Station 8.2. If you’re using older versions, you also have older API which may not support some channels (like HomeMode).

  1. Your load is too great

Please check the load of your DS. If it’s overloaded, please try to use one camera first and increase the refresh rates. Particularly Snapshot Thread is load consuming and might need to be increased.

Please check both cases as well as other channels, whether anything works at all. Please provide some log excerpts for your error cases (also per mail / PM).

DSM is 6.2 and Surveillance Station is 8.2, so this should be fine. However I don’t know where I can see the API version, whether it is built in Surveillance Station or is it a separate module eg the Device Pack of Surveillance Station, whose version is 5.7.3-2740.
If I try the following: http://192.168.0.16:5555/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=false&_sid=1kh9RPBHQb4aUD2L5N02809 (after having logged in and got the sid) it switches Home Home off respectively on with on=true. So my DS213 knows about HomeMode and reacts correctly to respective commands.
I tried this with both cameras deactivated, so there was no load problem. I will check the logs and will come back, hopefully with more insights.

Somehow I managed to have synologysurveillancestation work.
Yesterday I updated Surveillance Station to 8.2.4-5847, and since then the request from the binding to Synology (http://192.168.0.16:5555/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=GetInfo&_sid=[hidden1])
returns the following (sid replaced by [hidden1] (old sid) and by [hidden2] (new sid):

{“error”:{“code”:102},“success”:false}

My first idea was that sid is expired after the update, but then I rebooted OpenHAB. After that, the binding requested a new sid, but the error remained. Maybe the update breaks the binding?
Log after the reboot:

2019-06-25 08:58:48.751 [TRACE] [nternal.webapi.request.SynoApiCamera] - Device: camKeller, API response time: 43 ms, unexpected response: {“error”:{“code”:102},“success”:false}

2019-06-25 08:58:48.754 [DEBUG] [tation.internal.thread.SynoApiThread] - DeviceId: Bridge; Thread: Snapshot; SID expired, trying to reconnect

2019-06-25 08:58:48.762 [DEBUG] [ternal.webapi.request.SynoApiRequest] - http://192.168.0.16:5555/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=Login&_sid=[hidden1]&passwd=Smiles1!&session=SurveillanceStation&format=sid&account=Aurelio

2019-06-25 08:58:49.724 [DEBUG] [ternal.webapi.request.SynoApiRequest] - RESPONSE: {“data”:{“sid”:"[hidden2]"},“success”:true}

2019-06-25 08:58:50.112 [DEBUG] [tation.internal.thread.SynoApiThread] - Thread: HomeMode tick

2019-06-25 08:58:50.116 [DEBUG] [ternal.webapi.request.SynoApiRequest] - http://192.168.0.16:5555/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=GetInfo&_sid=[hidden2]

2019-06-25 08:58:50.171 [ERROR] [ternal.webapi.request.SynoApiRequest] - RESPONSE: {“error”:{“code”:102},“success”:false}

Furthermore, according to API Documentation 2.8 the error code 102 means that the API does not exist, something odd as the API didn’t seem to change since July 2018.

Odd that I didn’t notice it, but after the update Surveillance Station didn’t restart automatically, so I had to start the service manually. It might be useful for others that the Binding catches a 102 error with the possible reason that Surveillance Station is not running.

So it is working again I assume?

Yes it does, thank you. It was just a suggestion to catch that error to avoid others having the same problem as I had (or not recognizing the real problem). It seems something odd that Surveillance station gives a response although it doesn’t work, but thinking about it it is not Surveillance Station assigning an SID but DSM. That is what confused me in the first time, and that’s why catching the error might make things easier for others.

Hi all,

What is best practice for refresh of cameras?

I am using the Synology Surveillance station binding.

I have currently have 7 cameras.

The goal is to have a HABPanel running on our 40" screen in the Kitchen giving us an easy overview of our premises (Temp monitoring as well on the screen)
Today this is in place and working (Raspberry that turns on screen every morning and turns off every night… No problem)

My OH2 installation is running on a Raspberry pi 3. 16 gb flash.

Currently with refresh rate 0 on everything - It works and doesn’t crash.

As soon as I set the “Snapshot Refresh rate” to 3, 5 or even 10 I get the following pretty fast:

LOGS

2019-07-08 14:02:21.631 [vent.ItemStateChangedEvent] - Gangsti_Common_Snapshot changed from raw type (image/jpeg): 256678 bytes to raw type (image/jpeg): 255118 bytes
2019-07-08 14:02:22.426 [vent.ItemStateChangedEvent] - Carport2_Common_Snapshot changed from raw type (image/jpeg): 295416 bytes to raw type (image/jpeg): 298687 bytes
2019-07-08 14:02:26.297 [vent.ItemStateChangedEvent] - Have_Common_Snapshot changed from raw type (image/jpeg): 273226 bytes to raw type (image/jpeg): 272816 bytes
==> /var/log/openhab2/openhab.log <==
2019-07-08 14:02:33.780 [WARN ] [me.core.internal.events.EventHandler] - Dispatching event to subscriber ‘org.eclipse.smarthome.core.internal.items.ItemUpdater@1bfcfd6’ takes more than 5000ms.
==> /var/log/openhab2/events.log <==
2019-07-08 14:02:33.791 [vent.ItemStateChangedEvent] - Carport_Common_Snapshot changed from raw type (image/jpeg): 235856 bytes to raw type (image/jpeg): 236701 bytes
==> /var/log/openhab2/openhab.log <==
2019-07-08 14:02:43.456 [WARN ] [me.core.internal.events.EventHandler] - Dispatching event to subscriber ‘org.eclipse.smarthome.core.internal.items.ItemUpdater@1bfcfd6’ takes more than 5000ms.
2019-07-08 14:02:47.420 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘EventSubscriber.receive()’ on ‘org.eclipse.smarthome.core.internal.items.ItemUpdater@1bfcfd6’: Java heap space
java.lang.OutOfMemoryError: Java heap space

How can i show my cameras without the system crashing? What do others do (with more than 5 cameras?)
I dont expect live update, 5 seconds refresh could be okay.

Also when I have these refresh times for 3 seconds, my log will get totally spammed… This could as I understand tear on the SD card (And could be solved by mounting a seperate folder on a network drive for logs.)

This is my HABPanel:

One of the cameras with refresh rate 0 (currently):

Hi Jesper!

It’s a rather complex question so I can but give you some background and ideas to check:

  • I’m using just one camera on a much capable system with 10 seconds refresh rate. The obvious solution would be increasing refresh rate until it is stable.
  • If you’re getting Java heap space errors, you might want to increase memory size available for Java. Just try searching for “java heap space raspberry pi” on internet.
  • If you’re using HABPanel only, check my Lazy Widget available on project site (or search this thread for “Lazy”). It’s a rather old implementation, which may need to be adapted somehow, but its basic idea is to have zero refresh rate, relying on HABPanel to refresh images instead (and just as long as it’s open).

Frankly, I’ve tried to run OH on Raspberry PI myself and failed due to its hardware requirements. If you’re using Surveillance Station, you’re already having an Synology NAS up and running. Have you tried installing your openHAB there (as most users do afaik)?

Best regards
Pav

Hi Pavion,

Thanks for your response.

So using the Snapshot “changing picture on disk every X second” is the right approach (If I have a more powerful system)

That was basically what I was looking for. Got confused when I saw other channels:

  • Snapshot
  • Dynamic snapshot URI
  • Static snapshot URI
  • Live feed URI (rtsp)
  • Live feed URI (mjpeg over http)

I did run OH2 on a linux instance with 2gigs of memory and lots of power. (Here I had the system running between 7 days and 2 weeks before it died)

Today I launched a new Debian with 4Gigs of memory 4 kernels cpu. Will do a clean OH2 and play around with the Synology plugin and camera refresh rate while monitoring usage to see if I can see why and where it goes wrong :wink:

Will also look into the Lazy part. - It could make sense that the OH2 server shouldn’t use power on the updating/live view of the cameras, but the actual HABPanel client is the one updating/live viewing.

/J

SS does not support motion triggers from my camera, so I was hoping I could use OpenHAB to bridge the gap. The quality of the built in motion detection seems much lower than the system built into the camera. Using the Camera binding, I have got the the point where I have a Boolean item which is high at the right time. What is the best/simplest way to integrate this with this binding? I’m hoping to retain the functionality of normal motion detection in SS, where it will starts the recording before its event using a buffer.

Thanks!

Hi Alphie!

I can’t quite grasp what you’re trying to achieve.
You’re getting a motion detection signal from your camera and wanting to start recording some seconds before? I don’t think it’s possible as you’d practically need to record all the time.
Perhaps someone else have a solution, I have but two bad ideas:

  • continuous recording (and automatic deletion) with SS only, so you can at least check what was happening at the given time
  • make snapshots with the binding every X seconds, save to disk, delete files older then X min or move them to other folder while Boolean Item was triggered – all using rules – not quite sure how :slight_smile:

BR Pav

If you’re lucky enough to have a camera which SS fully supports (including motion detection) or you are willing to use SS’s motion detection, that’s exactly what happens when use motion detection mode. Whenever a trigger is received (either from SS or the camera’s own software), SS dumps its buffer into a new file and continues recording. I’ve seen this function called “timewarp” in other contexts.

SS does not recognize my camera as a motion trigger source, so I’m trying to find a workaround. The camera’s trigger state is getting as far as an OH item, so the part I’m missing is getting that into SS to be treated as a motion detection event. Even if it was picked up as a tampering event, I think it would would work just as well.

Binding to the Camera Recording channel is close, although it has these disadvantages:

  • No timewarp.
  • Does not show up in the SS timeline as motion.
  • I’m not sure how well it would work with the “low quality continuous, high quality on motion” strategy.

Another approach is using OH rules to map my booleans to the external triggers channel, then SS rules to use that number to stop and start recordings. That is more complicated and it appears to get me to the same place as directly mapping to the Camera Record channel.

Perhaps you should use both: oversensible motion detection of SS and parallel recording (and reporting) through this binding according to your event: if SS is recording already (in most cases), you’ll have your timewarp, otherwise you’ll trigger a new record with no timewarp. SS will then record often, but it’s just some more data in your RAID, which will be purged automatically.