Snapshot from Synology Surveillance station

I have a cheap IP Cam from China which is ONVIF compatible.

I cant get it imported in Vera. I can easily import it in Synology Surveillance station.

But I want it to sned me a snapahot like another (non-onvif) cam on triggered events.

It seems the Onvif cam hasnt got a snapshot path, at least not what I tried all (and thats a lot) and according to supplier (ebay).

After having lots of contact with Synology to find out if I can take a snapshot via the API of surveillance station it turned out it cannot be done via a single URL.

Is there anyone who knows or can help to take a valid snapshot from surveillance station?
I found some info here:

And the info from synology:
Surveillance Station doesn’t support the requirement that you said (snapshot from one URL), it has to obtain the authority first then do whatever else, othain snapshot or stream…etc.

that would be a cool integration… but is it worth the efforts??
Do you think you can get realtime capture done from Vera or will the action be missed by 2 seconds?

Sent from my GT-P3110 using Tapatalk

It’s possible to call Synology Surveillance Station Web API to get a snapshot. You can download it’s Web API doc from Synology site. I had a piece of LUA code to do something else on the Surveillance Station:

pleg_akbjson = require "akb-json"
pleg_http = require "socket.http"
pleg_sid = ""
pleg_logPrefix = "[PLEGLUA]"

function SSAuth()
  local ssSid = ""
	local loginUrl = "http://{SynologyIP:Port}/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account={username}&passwd={password}&session=SurveillanceStation&format=sid"
	local status, body, header
	local ret, msg
  
  body, status, headers = pleg_http.request(loginUrl)
	
  if status == 200 then
    luup.log(pleg_logPrefix .. "Returned JSON: " .. body)
    -- io.write("Returned JSON: " .. body)
    
    if pcall(function()
      ret, msg = pleg_akbjson.decode(body)
      ssSid = ret["data"]["sid"]
    end) then
      luup.log(pleg_logPrefix .. "SID: " .. ret["data"]["sid"])
      -- io.write("SID: " .. ret["data"]["sid"] .. "\r\n")
    else
      luup.log(pleg_logPrefix .. "Failed to get sid from request:")
      -- io.write("Failed to get sid from request\r\n")
    end
  else
    luup.log(pleg_logPrefix .. "There is a problem from the server. HTTP: " .. status)
    -- io.write("There is a problem from the server. HTTP: " .. status .. "\r\n")
  end
  
  return ssSid
end

function SSLogout()
  local logoutUrl = "http://{SynologyIP}:Port}/webapi/auth.cgi?api=SYNO.API.Auth&method=Logout&version=2&session=SurveillanceStation&_sid=" .. pleg_sid
  local status, body, header
	local ret, msg
  
  body, status, headers = pleg_http.request(logoutUrl)
  
  if status == 200 then
    luup.log(pleg_logPrefix .. "Returned JSON: " .. body)
    
    if pcall(function()
      ret, msg = pleg_akbjson.decode(body)
      
      if ret["success"] == true then
        luup.log(pleg_logPrefix .. "Successfully logged out.")
      end
    end) then
      luup.log(pleg_logPrefix .. "There is a problem from the server. HTTP: " .. status)
    end
  end
end

function SetSSMotionDetection(on)
  local setUrl = ""
  local ret, msg
  local status, body, header
  local success = false
  
  if pleg_sid == "" then
    luup.log("There is no auth sid.\r\n")
    -- io.write("There is not auth sid.\r\n")
    return false
  end
  
  if on then
    setUrl = "http://{SynologyIP}:Port}/webapi/entry.cgi?version=\"1\"&api=\"SYNO.SurveillanceStation.Camera.Event\"&method=\"MDParamSave\"&source=1&camId=3&keep=true&_sid=" .. pleg_sid
  else
    setUrl = "http://{SynologyIP}:Port}/webapi/entry.cgi?version=\"1\"&api=\"SYNO.SurveillanceStation.Camera.Event\"&method=\"MDParamSave\"&source=-1&camId=3&keep=true&_sid=" .. pleg_sid
  end  
  
	body, status, headers = pleg_http.request(setUrl)
  
  if status == 200 then
    luup.log("Returned JSON: " .. body .. "\r\n")
    -- io.write("Returned JSON: " .. body .. "\r\n")
    
    if pcall(function ()
      ret, msg = pleg_akbjson.decode(body)
      if ret["success"] == true then
        success = true
      else
        luup.log(pleg_logPrefix .. "Failed setting motion detection to " .. tostring(switch) .. "\r\n")
        -- io.write("Failed setting motion detection to " .. tostring(switch) .. "\r\n")
      end
    end) then
      luup.log(pleg_logPrefix .. "Turned motino detection: " .. tostring(on) .. "\r\n")
      -- io.write("Turned motino detection: " .. tostring(on) .. "\r\n")
    else
      luup.log(pleg_logPrefix .. "There is a problem parsing response\r\n")
      -- io.write("There is a problem parsing response\r\n")
    end
  end
  
  return success
end

Dreamcryer, I know it’s possible with surveillance station. Please read the first post. In order to “snap” for an event I need the camera to be imported as a camera in vera. Therefore I need a SINGLE URL to get the snap from the camera or surveillance station. Since the camera is an onvif camera and doesn’t support a snap via url I wondered and asked in this topic for such an option via surveillance station.

@ Sender did you ever find out how to get a snapshot from surveillance station? I would like to do the same and I was hoping you could share the lua for this action.

Hello,
I’ve implemented snapshots in the Surveillance Station Remote plugin.
I will push my modifications as soon as I can.

Hi, never made it via Vera… but I did it via taking a snapshot via my Synology NAS and a PHP script. via many sources, I don’t know which ones anymore, I have scraped the script in the attachment together and created a working one for me. Just place it on a web server supporting the PHP hosting and fill in the correct credentials etc. and call it via a web browser shows you an instant snap of the cam.

Sometimes it doesn’t work (1 out of 10) but I don’t know why.

Thanks @vosmont, looking forward to your update.

Thanks @Sender, nice to have several options.

Hi @vosmont, I know you have lots of plugins on your plate but did you ever get around to pushing your Surveillance Station Remote plugin modifications?

Seems like the version available is still quite old:

Surveillance Station Remote
Updated:2015-02-03 05:05:18
Current Version:0.6

Sorry korttoma…
I will check that tonight and push my modifications on Github.
I’ve made a lot of internal changes in the plugin.

Hello,

there’s a new version on Github :

It seems to have problem to swith on/off cameras by group (no problem one by one)

Thanks @vosmont for the update now I installed the plugin.

I encountered some issues:

What should I add to the “Cameras” variable to be able to see my camera under the Cameras tab?

Disabling/enabling the camera I have from the dashboard seems to work fine but the recording button does not seem to work.

Under the error view I found this event:
6/23/2016, 9:30:00 AM API error: Insufficient user privilege (105)

(The user I created to my NAS has all the privileges I could give him)

Hello,

You will find in the “Errors” tab, all the errors that the plugin has encountered (the last 100).
The error “Insufficient user privilege (105)” is raised when the user has not enougth privilege or is not authentifiate.

When the plugin detects this error, it tries to login in.
So you should see this error just one time, before the login.

The variable “Cameras” is no more used. The plugin uses now http request handler.

Your cameras, present in Surveillance Station, should appear in the tab “Cameras”.
If not there’s a problem : you can activate the debug by setting the variable “DebugMode” to “1” (and see the logs)

Yeah the error was probably generated during configuration of the plugin since it only appeared once.

I can still not see my camera under the Cameras tab.

I see from the log that my camera is polled without issues:
06/23/16 12:42:56.454 luup_log:199: (SurveillanceStationRemote::Cameras.update) Camera #1 ‘{ “enabled”: true, “name”: “FI9828P”, “id”: 1, “camStatus”: 1, “recStatus”: 0, “status”: 0 }’

But maybe you can see something I don’t from the log:

It’s weird, there’s no log about snapshot.

Have you refreshed your browser ?
In the tab “Cameras”, you should have the list of your camera and an image (snapshot).
For the moment, the snapshot is not refreshed (it could take some seconds to be displayed)

You can also get the snapshot by calling directly the URL :
htt://vera_ip:3480/data_request?id=lr_SurveillanceStationRemote_{deviceId}&command=getSnapshot&cameraId={cameraId}

Yeah, I have refreshed and even tried a different browser but the Cameras tab under the plugin is stil empty.

The URL you posted does return a snapshot in the browser just like you said so the plugin seems functional except for the user interface under the cameras tab.

You will find a patch on Github

Your patch worked like a charm :wink: thanks vosmont!

Hi @vosmont I know this is an old thread but I need to find out how to define the http string for a snapshot
And you did this in a script but I really need to create the actual link (To show up on a “smart tile board”)

Could you help explain how you did this? sofar I have tried with many variations:

https://192.168.0.10:5001/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=GetLiveViewPath&version=9&idList=3&_sid=VmeC4CgYlARRg14A0MQN414008

I can also see that its now possible to set token rstp streams in Synology now (Permanent ones) so could I just copy that token? and somehow use it to get a simpel snapshot?

rtsp://syno:b22890d5f7d8bf8adc6214e502c1xxxx@192.168.0.10:554/Sms=11.unicast
(This works but I need to get the http:// for a snapshot :slight_smile:

thanks for all your work!