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/frigate/video.py b/frigate/video.py index abf490a72..91e92fee1 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -113,8 +113,10 @@ def capture_frames( def get_enabled_state(): """Fetch the latest enabled state from ZMQ.""" _, config_data = config_subscriber.check_for_update() + if config_data: - return config_data.enabled + config.enabled = config_data.enabled + return config.enabled while not stop_event.is_set(): diff --git a/web/src/api/ws.tsx b/web/src/api/ws.tsx index 5eedcdbcd..3e9c8c14f 100644 --- a/web/src/api/ws.tsx +++ b/web/src/api/ws.tsx @@ -44,7 +44,8 @@ function useValue(): useValueReturn { return; } - const cameraActivity: { [key: string]: object } = JSON.parse(activityValue); + const cameraActivity: { [key: string]: FrigateCameraState } = + JSON.parse(activityValue); if (Object.keys(cameraActivity).length === 0) { return; @@ -64,9 +65,7 @@ function useValue(): useValueReturn { autotracking, alerts, detections, - } = - // @ts-expect-error we know this is correct - state["config"]; + } = state["config"]; cameraStates[`${name}/recordings/state`] = record ? "ON" : "OFF"; cameraStates[`${name}/enabled/state`] = enabled ? "ON" : "OFF"; cameraStates[`${name}/detect/state`] = detect ? "ON" : "OFF"; @@ -174,7 +173,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 b73e7991c..51af9877d 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -385,7 +385,10 @@ export default function LivePlayer({