From ee8091ba91f33b8ddf883a1ff9182af8692073f4 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:48:56 -0500 Subject: [PATCH] Correctly handle camera command in dispatcher (#14273) --- frigate/comms/dispatcher.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frigate/comms/dispatcher.py b/frigate/comms/dispatcher.py index 12dfe2731..8b310a4bb 100644 --- a/frigate/comms/dispatcher.py +++ b/frigate/comms/dispatcher.py @@ -91,14 +91,14 @@ class Dispatcher: def _receive(self, topic: str, payload: str) -> Optional[Any]: """Handle receiving of payload from communicators.""" - def handle_camera_command(command_type, camera_name, payload): + def handle_camera_command(command_type, camera_name, command, payload): try: if command_type == "set": - self._camera_settings_handlers[camera_name](camera_name, payload) + self._camera_settings_handlers[command](camera_name, payload) elif command_type == "ptz": self._on_ptz_command(camera_name, payload) except KeyError: - logger.error(f"Invalid command type: {command_type}") + logger.error(f"Invalid command type or handler: {command_type}") def handle_restart(): restart_frigate() @@ -203,14 +203,14 @@ class Dispatcher: # example /cam_name/detect/set payload=ON|OFF camera_name = parts[-3] command = parts[-2] - handle_camera_command("set", camera_name, payload) + handle_camera_command("set", camera_name, command, payload) elif len(parts) == 2 and topic.endswith("set"): command = parts[-2] self._global_settings_handlers[command](payload) elif len(parts) == 2 and topic.endswith("ptz"): # example /cam_name/ptz payload=MOVE_UP|MOVE_DOWN|STOP... camera_name = parts[-2] - handle_camera_command("ptz", camera_name, payload) + handle_camera_command("ptz", camera_name, "", payload) except IndexError: logger.error( f"Received invalid {topic.split('/')[-1]} command: {topic}"