From e2a776556dd9b7c01fdf8198320250d69b76290a Mon Sep 17 00:00:00 2001 From: Shea Smith <51303984+SheaSmith@users.noreply.github.com> Date: Sat, 27 Nov 2021 03:05:38 +0000 Subject: [PATCH] Add stopping --- frigate/http.py | 20 ++++++++++++++++++++ frigate/ptz.py | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/frigate/http.py b/frigate/http.py index eb8dc94d6..98ffdcb88 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -459,6 +459,26 @@ def ptz_sethome(camera_name): return "Camera named {} not found".format(camera_name), 404 +@bp.route("//ptz/stop") +def ptz_stop(camera_name): + if ( + camera_name in current_app.frigate_config.cameras + and current_app.frigate_config.cameras[camera_name].onvif.host is not None + ): + if current_app.ptz_cameras.get(camera_name) is None: + current_app.ptz_cameras[camera_name] = Ptz( + current_app.frigate_config.cameras[camera_name] + ) + + ptz = current_app.ptz_cameras[camera_name] + + ptz.stop() + + return "", 204 + else: + return "Camera named {} not found".format(camera_name), 404 + + @bp.route("//ptz/gotohome") def ptz_gotohome(camera_name): if ( diff --git a/frigate/ptz.py b/frigate/ptz.py index 97ffa9840..36be2aadb 100644 --- a/frigate/ptz.py +++ b/frigate/ptz.py @@ -98,3 +98,12 @@ class Ptz: request.Speed.PanTilt.x = self.turn_speed request.Speed.PanTilt.y = self.turn_speed self.ptz_service.GotoPreset(request) + + def stop(self): + request = { + "ProfileToken": self.move_request.ProfileToken, + "PanTilt": True, + "Zoom": True, + } + self.ptz_service.Stop(request) + self.active = False