From eb73a37fc3f326fe6f0e57b85b35c343476da4f5 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Sun, 16 Jan 2022 22:30:02 +0000 Subject: [PATCH 1/2] in python3 .values() returns dict_values object not a list, need to explicitly cast to list --- src/synology_dsm/api/surveillance_station/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/synology_dsm/api/surveillance_station/__init__.py b/src/synology_dsm/api/surveillance_station/__init__.py index 001ab6cd..3fded43f 100644 --- a/src/synology_dsm/api/surveillance_station/__init__.py +++ b/src/synology_dsm/api/surveillance_station/__init__.py @@ -55,7 +55,7 @@ def get_info(self): # Camera def get_all_cameras(self): """Return a list of cameras.""" - return self._cameras_by_id.values() + return list(self._cameras_by_id.values()) def get_camera(self, camera_id): """Return camera matching camera_id.""" From 67c9a4254f6e59eff7c4e357d0904d2c76d14387 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Tue, 18 Jan 2022 21:56:22 +0000 Subject: [PATCH 2/2] Corrected README example for Surveillance station to use .id not .camera_id Added SYNO.SurveillanceStation.ExternalEvent API wrapper --- README.rst | 4 ++-- src/synology_dsm/api/surveillance_station/__init__.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 753ab9a0..eef727ad 100644 --- a/README.rst +++ b/README.rst @@ -169,8 +169,8 @@ Surveillance Station usage # Returns a list of cached cameras available cameras = surveillance.get_all_cameras() - # Assuming there's at least one camera, get the first camera_id - camera_id = cameras[0].camera_id + # Assuming there's at least one camera, get the first camera id + camera_id = cameras[0].id # Returns cached camera object by camera_id camera = surveillance.get_camera(camera_id) diff --git a/src/synology_dsm/api/surveillance_station/__init__.py b/src/synology_dsm/api/surveillance_station/__init__.py index 3fded43f..d1e42411 100644 --- a/src/synology_dsm/api/surveillance_station/__init__.py +++ b/src/synology_dsm/api/surveillance_station/__init__.py @@ -13,6 +13,7 @@ class SynoSurveillanceStation: CAMERA_EVENT_API_KEY = "SYNO.SurveillanceStation.Camera.Event" HOME_MODE_API_KEY = "SYNO.SurveillanceStation.HomeMode" SNAPSHOT_API_KEY = "SYNO.SurveillanceStation.SnapShot" + EXTEVENT_API_KEY = "SYNO.SurveillanceStation.ExternalEvent" def __init__(self, dsm): """Initialize a Surveillance Station.""" @@ -136,6 +137,14 @@ def disable_motion_detection(self, camera_id): {"camId": camera_id, "source": MOTION_DETECTION_DISABLED}, ) + def ext_event_trigger(self,eventId=1,event_message="event_message"): + """Trigger external event""" + return self._dsm.get( + self.EXTEVENT_API_KEY, + "Trigger", + {"eventId": eventId, "eventName": event_message}, + ) + # Home mode def get_home_mode_status(self): """Get the state of Home Mode."""