Skip to content

Add SurveillanceStation#57

Merged
Quentame merged 27 commits intoProtoThis:masterfrom
Quentame:surveillance_station/add
Jun 28, 2020
Merged

Add SurveillanceStation#57
Quentame merged 27 commits intoProtoThis:masterfrom
Quentame:surveillance_station/add

Conversation

@Quentame
Copy link
Copy Markdown
Collaborator

@Quentame Quentame commented Jun 2, 2020

TODO:

@Quentame Quentame added this to the 0.9.0 milestone Jun 2, 2020
@Quentame Quentame force-pushed the surveillance_station/add branch from be34c69 to e349d54 Compare June 2, 2020 23:34
Comment thread synology_dsm/synology_dsm.py
Comment thread synology_dsm/api/surveillance_station/__init__.py Outdated
Comment thread synology_dsm/api/surveillance_station/__init__.py Outdated
Comment thread synology_dsm/api/surveillance_station/__init__.py Outdated
@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 3, 2020

I added some api data. https://github.com/shenxn/python-synology/tree/surveillance_station/add/tests/api_data/dsm_6/surveillance_station

Quentame and others added 2 commits June 3, 2020 09:13
Co-authored-by: Xiaonan Shen <s@sxn.dev>
Co-authored-by: Xiaonan Shen <s@sxn.dev>
Comment thread synology_dsm/api/surveillance_station/camera.py Outdated
Comment thread synology_dsm/api/surveillance_station/camera.py
@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 3, 2020

Since now we have several API version issues, I'm thinking if we should fix our integration to use some specific versions of API instead of the maximum supported one to avoid new API releases break the integration.

Edit: Note that some people want to integrate with older devices (home-assistant/core#35475). Maybe it is better to build this based on API version 1 and use higher versions for some methods only.

Co-authored-by: Xiaonan Shen <s@sxn.dev>
@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 3, 2020

Hint for test: Surveillance Station supports adding camera from .mp4 files, so that you can set up a "camera" without actually have any cameras. It should be sufficient to do API tests.

@Quentame
Copy link
Copy Markdown
Collaborator Author

Quentame commented Jun 3, 2020

Since now we have several API version issues, I'm thinking if we should fix our integration to use some specific versions of API instead of the maximum supported one to avoid new API releases break the integration.

Edit: Note that some people want to integrate with older devices (home-assistant/core#35475). Maybe it is better to build this based on API version 1 and use higher versions for some methods only.

The previous library uses fixed API version, here it used automatic from API info.

I think we should keep it auto/higher so we can use newer functions, then handle SynologyDSMAPINotExistsException or SynologyDSMAPIErrorException or condition, based on API & version, to make a specific request on this.

For home-assistant/core#35475:

  • first issue: the 400 error can come from a lot of things that are odd, I think it needs more details to solve (Surveillance error codes and meaning:
    # SYNO.SurveillanceStation.*
    ERROR_SURVEILLANCE = {
    400: "Execution failed",
    401: "Invalid parameter",
    402: "Camera disabled",
    403: "Insufficient license",
    404: "Codec activation failed",
    405: "CMS server connection failed",
    407: "CMS closed",
    412: "Need to add license",
    413: "Reach the maximum of platform",
    414: "Some events not exist",
    415: "Message connect failed",
    417: "Test connection error",
    418: "Object/VisualStation ID does not exist",
    419: "VisualStation name repetition",
    439: "Too many items selected",
    446: "Task path already exist",
    522: "Original task is migrating",
    534: "Exceed name length limitation",
    }
    )
  • second issue: timeout with wrong livestreaming implementation (Using GetLiveViewPath as here may fix its problem, it provides mjpeg url with SYNO.SurveillanceStation.VideoStreaming, instead of SYNO.SurveillanceStation.VideoStream 🤔)
  • It already uses https://github.com/snjoetw/py-synology with version 1, so maybe using a higher version will solve the issue 😂 "let's find out!"

We are having no risk to make this guy working even less 😂

@Quentame
Copy link
Copy Markdown
Collaborator Author

Quentame commented Jun 3, 2020

Can you check also snjoetw/py-synology#12 (comment) ?

The documentation is telling boolean, but was int in the lib.

@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 3, 2020

@Quentame For home-assistant/core#35475, I can see KeyError: 'SYNO.SurveillanceStation.Camera.Event' in the log. This is expected since the Event API is only supported in Surveillance Station 7.0+, event it is API version 1. I guess we can handle these things later. The second issue should be fixed by using GetLiveViewPath.

@Quentame
Copy link
Copy Markdown
Collaborator Author

Quentame commented Jun 3, 2020

Oh yep! I did not see the KeyError

I agree.

@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 3, 2020

@Quentame Tested the TakeSnapshot method. It should be int. The API treats anything other than 0 as true.

@Quentame
Copy link
Copy Markdown
Collaborator Author

Quentame commented Jun 9, 2020

Hi again @shenxn !

Can you provide me a data for SYNO.SurveillanceStation.Camera with method GetInfo ?
So that it will make the tests working.

After that, one last test so I can merge soon.

@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 10, 2020

@Quentame GetInfo is removed in API version 9, unfortunately. And API version 8 of GetInfo returns very little information, less than the List method. The highest version that gives enough info is API version 7 and the List method of API version 7 seems to return exactly the same info as GetInfo. So I guess we need to use lower API version at least on some methods.

@Quentame
Copy link
Copy Markdown
Collaborator Author

Ok will do that, add a max to 7.

Let’s see us tomorrow or the day after 😉

@Quentame
Copy link
Copy Markdown
Collaborator Author

Updated to use the list with v7 at max API version

@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 19, 2020

@Quentame I've updated the API data of the list method (https://github.com/shenxn/python-synology/blob/surveillance_station/add/tests/api_data/dsm_6/surveillance_station/const_6_surveillance_station_camera.py). I'll do more tests on other methods.

@Quentame
Copy link
Copy Markdown
Collaborator Author

@shenxn don’t hesitate to ping me if you need something.

Comment thread synology_dsm/api/surveillance_station/__init__.py Outdated
@shenxn
Copy link
Copy Markdown
Contributor

shenxn commented Jun 19, 2020

@Quentame I added a little more API data (https://github.com/shenxn/python-synology/blob/surveillance_station/add/tests/api_data/dsm_6/surveillance_station). Everything seems working well as long as the Switch method is fixed.

Quentame and others added 5 commits June 27, 2020 01:50
Co-authored-by: Xiaonan Shen <s@sxn.dev>
Co-authored-by: Joe Lu <snjoetw@gmail.com>

Co-authored-by: David <dconnor@gmail.com>

Co-authored-by: Aleksander Lyse <aleksander.lyse@gmail.com>

Co-authored-by: Loïc Gerbaud <info@loicg.net>
@Quentame
Copy link
Copy Markdown
Collaborator Author

Will release the lib this week-end or during the week, get ready 😉

@Quentame
Copy link
Copy Markdown
Collaborator Author

Quentame commented Jun 28, 2020

I installed Surveillance Station and try to add a camera from a mp4 file (brand: [user defined], type: file).

When it tests the cam, I got the message "Failed to test the camera", tried with multiple files, I don't know why it's not working.

@Quentame Quentame merged commit 3045935 into ProtoThis:master Jun 28, 2020
@Quentame Quentame deleted the surveillance_station/add branch June 28, 2020 23:23
Quentame added a commit to Quentame/python-synology that referenced this pull request Jun 28, 2020
* Add SurveillanceStation

* Fix error in error handling

* Fix Python 2.7 pylint

* Capitalize Camera_API.List

Co-authored-by: Xiaonan Shen <s@sxn.dev>

* Capitalize Camera_API.GetSnapshot + id instead of cameraId

Co-authored-by: Xiaonan Shen <s@sxn.dev>

* Join idList

Co-authored-by: Xiaonan Shen <s@sxn.dev>

* black

* pylint

* methods are case sensitive

* Backward compat with Camera.GetSnapshot cameraId

* raw live view data

* Add Info.GetInfo

* Use Camera.GetInfo

* Fix TakeSnapshot blSave

* Fix content type

* Add SurveillanceStation api data

* Add unit test, miss SYNO.SurveillanceStation.Camera GetInfo

* Do not use Camera.LetInfo but .List with max_version 7

* Fix Switch on param

Co-authored-by: Xiaonan Shen <s@sxn.dev>

* Update camera list api data

* Add more API data

* Take care of new test data

* Add RTSP test + previous library code owners

Co-authored-by: Joe Lu <snjoetw@gmail.com>

Co-authored-by: David <dconnor@gmail.com>

Co-authored-by: Aleksander Lyse <aleksander.lyse@gmail.com>

Co-authored-by: Loïc Gerbaud <info@loicg.net>

* Fix Py27 pipe

* Fix : get_all_cameras() test

* Update README for SurveillanceStation

* Fix README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants