From 709409b6c54220a78450c20f21a3564ea67197e2 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 20 Mar 2025 09:17:41 -0600 Subject: [PATCH] Ensure camera always have config object updated --- frigate/camera/state.py | 1 - frigate/comms/dispatcher.py | 6 +++++- web/src/api/ws.tsx | 2 +- web/src/components/player/LivePlayer.tsx | 15 +++++---------- web/src/types/ws.ts | 4 +++- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frigate/camera/state.py b/frigate/camera/state.py index 0e02c6c14..f2469dffd 100644 --- a/frigate/camera/state.py +++ b/frigate/camera/state.py @@ -306,7 +306,6 @@ class CameraState: # TODO: can i switch to looking this up and only changing when an event ends? # maintain best objects camera_activity: dict[str, list[any]] = { - "enabled": True, "motion": len(motion_boxes) > 0, "objects": [], } diff --git a/frigate/comms/dispatcher.py b/frigate/comms/dispatcher.py index 586b70cbb..4c0b0a8ff 100644 --- a/frigate/comms/dispatcher.py +++ b/frigate/comms/dispatcher.py @@ -164,8 +164,12 @@ class Dispatcher: def handle_on_connect(): camera_status = self.camera_activity.last_camera_activity.copy() + cameras_with_status = camera_status.keys() + + for camera in self.config.cameras.keys(): + if camera not in cameras_with_status: + camera_status[camera] = {} - for camera in camera_status.keys(): camera_status[camera]["config"] = { "detect": self.config.cameras[camera].detect.enabled, "enabled": self.config.cameras[camera].enabled, diff --git a/web/src/api/ws.tsx b/web/src/api/ws.tsx index 5eedcdbcd..27600993a 100644 --- a/web/src/api/ws.tsx +++ b/web/src/api/ws.tsx @@ -174,7 +174,7 @@ export function useEnabledState(camera: string): { value: { payload }, send, } = useWs(`${camera}/enabled/state`, `${camera}/enabled/set`); - return { payload: (payload ?? "ON") as ToggleableSetting, send }; + return { payload: payload as ToggleableSetting, send }; } export function useDetectState(camera: string): { diff --git a/web/src/components/player/LivePlayer.tsx b/web/src/components/player/LivePlayer.tsx index a9cb33b2a..51af9877d 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -91,21 +91,13 @@ export default function LivePlayer({ // camera activity const { - enabled: cameraWasEnabled, + enabled: cameraEnabled, activeMotion, activeTracking, objects, offline, } = useCameraActivity(cameraConfig); - const cameraEnabled = useMemo(() => { - if (!cameraWasEnabled) { - return false; - } - - return cameraConfig.enabled; - }, [cameraConfig, cameraWasEnabled]); - const cameraActive = useMemo( () => !showStillWithoutActivity || @@ -393,7 +385,10 @@ export default function LivePlayer({