From e90754ddf6fccbca32474b29c53cc2419b5be5ef Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 5 Mar 2026 12:56:53 -0600 Subject: [PATCH] wire ProfileManager into app startup and FastAPI - Create ProfileManager after dispatcher init - Restore persisted profile on startup - Pass dispatcher and profile_manager to FastAPI app --- frigate/api/fastapi_app.py | 4 ++++ frigate/app.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/frigate/api/fastapi_app.py b/frigate/api/fastapi_app.py index 1e8c408e6..4e022ca89 100644 --- a/frigate/api/fastapi_app.py +++ b/frigate/api/fastapi_app.py @@ -68,6 +68,8 @@ def create_fastapi_app( event_metadata_updater: EventMetadataPublisher, config_publisher: CameraConfigUpdatePublisher, replay_manager: DebugReplayManager, + dispatcher=None, + profile_manager=None, enforce_default_admin: bool = True, ): logger.info("Starting FastAPI app") @@ -149,6 +151,8 @@ def create_fastapi_app( app.event_metadata_updater = event_metadata_updater app.config_publisher = config_publisher app.replay_manager = replay_manager + app.dispatcher = dispatcher + app.profile_manager = profile_manager if frigate_config.auth.enabled: secret = get_jwt_secret() diff --git a/frigate/app.py b/frigate/app.py index 7c8ac47e3..0828bb8e3 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -30,6 +30,7 @@ from frigate.comms.ws import WebSocketClient from frigate.comms.zmq_proxy import ZmqProxy from frigate.config.camera.updater import CameraConfigUpdatePublisher from frigate.config.config import FrigateConfig +from frigate.config.profile_manager import ProfileManager from frigate.const import ( CACHE_DIR, CLIPS_DIR, @@ -348,6 +349,19 @@ class FrigateApp: comms, ) + def init_profile_manager(self) -> None: + self.profile_manager = ProfileManager( + self.config, self.inter_config_updater + ) + self.dispatcher.profile_manager = self.profile_manager + + persisted = ProfileManager.load_persisted_profile() + if persisted and any( + persisted in cam.profiles for cam in self.config.cameras.values() + ): + logger.info("Restoring persisted profile '%s'", persisted) + self.profile_manager.activate_profile(persisted) + def start_detectors(self) -> None: for name in self.config.cameras.keys(): try: @@ -556,6 +570,7 @@ class FrigateApp: self.init_inter_process_communicator() self.start_detectors() self.init_dispatcher() + self.init_profile_manager() self.init_embeddings_client() self.start_video_output_processor() self.start_ptz_autotracker() @@ -585,6 +600,8 @@ class FrigateApp: self.event_metadata_updater, self.inter_config_updater, self.replay_manager, + self.dispatcher, + self.profile_manager, ), host="127.0.0.1", port=5001,