mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-10 10:33:11 +03:00
consolidate
This commit is contained in:
parent
81e39c3806
commit
1b0d78c40e
@ -6,7 +6,6 @@ from ..base import FrigateBaseModel
|
|||||||
from .audio import AudioConfig
|
from .audio import AudioConfig
|
||||||
from .birdseye import BirdseyeCameraConfig
|
from .birdseye import BirdseyeCameraConfig
|
||||||
from .detect import DetectConfig
|
from .detect import DetectConfig
|
||||||
from .live import CameraLiveConfig
|
|
||||||
from .motion import MotionConfig
|
from .motion import MotionConfig
|
||||||
from .notification import NotificationConfig
|
from .notification import NotificationConfig
|
||||||
from .objects import ObjectConfig
|
from .objects import ObjectConfig
|
||||||
@ -28,7 +27,6 @@ class CameraProfileConfig(FrigateBaseModel):
|
|||||||
audio: Optional[AudioConfig] = None
|
audio: Optional[AudioConfig] = None
|
||||||
birdseye: Optional[BirdseyeCameraConfig] = None
|
birdseye: Optional[BirdseyeCameraConfig] = None
|
||||||
detect: Optional[DetectConfig] = None
|
detect: Optional[DetectConfig] = None
|
||||||
live: Optional[CameraLiveConfig] = None
|
|
||||||
motion: Optional[MotionConfig] = None
|
motion: Optional[MotionConfig] = None
|
||||||
notifications: Optional[NotificationConfig] = None
|
notifications: Optional[NotificationConfig] = None
|
||||||
objects: Optional[ObjectConfig] = None
|
objects: Optional[ObjectConfig] = None
|
||||||
|
|||||||
@ -9,25 +9,13 @@ from frigate.config.camera.updater import (
|
|||||||
CameraConfigUpdatePublisher,
|
CameraConfigUpdatePublisher,
|
||||||
CameraConfigUpdateTopic,
|
CameraConfigUpdateTopic,
|
||||||
)
|
)
|
||||||
|
from frigate.const import CONFIG_DIR
|
||||||
from frigate.util.builtin import deep_merge
|
from frigate.util.builtin import deep_merge
|
||||||
from frigate.util.config import apply_section_update
|
from frigate.util.config import apply_section_update
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
PROFILE_SECTIONS = {
|
PROFILE_SECTION_UPDATES: dict[str, CameraConfigUpdateEnum] = {
|
||||||
"audio",
|
|
||||||
"birdseye",
|
|
||||||
"detect",
|
|
||||||
"live",
|
|
||||||
"motion",
|
|
||||||
"notifications",
|
|
||||||
"objects",
|
|
||||||
"record",
|
|
||||||
"review",
|
|
||||||
"snapshots",
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION_TO_UPDATE_ENUM: dict[str, CameraConfigUpdateEnum] = {
|
|
||||||
"audio": CameraConfigUpdateEnum.audio,
|
"audio": CameraConfigUpdateEnum.audio,
|
||||||
"birdseye": CameraConfigUpdateEnum.birdseye,
|
"birdseye": CameraConfigUpdateEnum.birdseye,
|
||||||
"detect": CameraConfigUpdateEnum.detect,
|
"detect": CameraConfigUpdateEnum.detect,
|
||||||
@ -39,7 +27,7 @@ SECTION_TO_UPDATE_ENUM: dict[str, CameraConfigUpdateEnum] = {
|
|||||||
"snapshots": CameraConfigUpdateEnum.snapshots,
|
"snapshots": CameraConfigUpdateEnum.snapshots,
|
||||||
}
|
}
|
||||||
|
|
||||||
PERSISTENCE_FILE = Path("/config/.active_profile")
|
PERSISTENCE_FILE = Path(CONFIG_DIR) / ".active_profile"
|
||||||
|
|
||||||
|
|
||||||
class ProfileManager:
|
class ProfileManager:
|
||||||
@ -61,7 +49,7 @@ class ProfileManager:
|
|||||||
"""Snapshot each camera's current section configs as the base."""
|
"""Snapshot each camera's current section configs as the base."""
|
||||||
for cam_name, cam_config in self.config.cameras.items():
|
for cam_name, cam_config in self.config.cameras.items():
|
||||||
self._base_configs[cam_name] = {}
|
self._base_configs[cam_name] = {}
|
||||||
for section in PROFILE_SECTIONS:
|
for section in PROFILE_SECTION_UPDATES:
|
||||||
section_config = getattr(cam_config, section, None)
|
section_config = getattr(cam_config, section, None)
|
||||||
if section_config is not None:
|
if section_config is not None:
|
||||||
self._base_configs[cam_name][section] = section_config.model_dump()
|
self._base_configs[cam_name][section] = section_config.model_dump()
|
||||||
@ -110,7 +98,7 @@ class ProfileManager:
|
|||||||
"""Reset all cameras to their base (no-profile) config."""
|
"""Reset all cameras to their base (no-profile) config."""
|
||||||
for cam_name, cam_config in self.config.cameras.items():
|
for cam_name, cam_config in self.config.cameras.items():
|
||||||
base = self._base_configs.get(cam_name, {})
|
base = self._base_configs.get(cam_name, {})
|
||||||
for section in PROFILE_SECTIONS:
|
for section in PROFILE_SECTION_UPDATES:
|
||||||
base_data = base.get(section)
|
base_data = base.get(section)
|
||||||
if base_data is None:
|
if base_data is None:
|
||||||
continue
|
continue
|
||||||
@ -136,7 +124,7 @@ class ProfileManager:
|
|||||||
|
|
||||||
base = self._base_configs.get(cam_name, {})
|
base = self._base_configs.get(cam_name, {})
|
||||||
|
|
||||||
for section in PROFILE_SECTIONS:
|
for section in PROFILE_SECTION_UPDATES:
|
||||||
profile_section = getattr(profile, section, None)
|
profile_section = getattr(profile, section, None)
|
||||||
if profile_section is None:
|
if profile_section is None:
|
||||||
continue
|
continue
|
||||||
@ -164,7 +152,7 @@ class ProfileManager:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for section in sections:
|
for section in sections:
|
||||||
update_enum = SECTION_TO_UPDATE_ENUM.get(section)
|
update_enum = PROFILE_SECTION_UPDATES.get(section)
|
||||||
if update_enum is None:
|
if update_enum is None:
|
||||||
continue
|
continue
|
||||||
settings = getattr(cam_config, section, None)
|
settings = getattr(cam_config, section, None)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user