From 3dd401f57a8eaf6c0f8a70404f8dd538e1683199 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 29 May 2024 09:19:05 -0500 Subject: [PATCH] string or list for camera groups (#11616) --- frigate/config.py | 10 +++++++++- web/src/components/filter/CameraGroupSelector.tsx | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frigate/config.py b/frigate/config.py index 6d0342d98..6190413a7 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -1171,12 +1171,20 @@ class LoggerConfig(FrigateBaseModel): class CameraGroupConfig(FrigateBaseModel): """Represents a group of cameras.""" - cameras: list[str] = Field( + cameras: Union[str, List[str]] = Field( default_factory=list, title="List of cameras in this group." ) icon: str = Field(default="generic", title="Icon that represents camera group.") order: int = Field(default=0, title="Sort order for group.") + @field_validator("cameras", mode="before") + @classmethod + def validate_cameras(cls, v): + if isinstance(v, str) and "," not in v: + return [v] + + return v + def verify_config_roles(camera_config: CameraConfig) -> None: """Verify that roles are setup in the config correctly.""" diff --git a/web/src/components/filter/CameraGroupSelector.tsx b/web/src/components/filter/CameraGroupSelector.tsx index 54320f29a..d9fc9f420 100644 --- a/web/src/components/filter/CameraGroupSelector.tsx +++ b/web/src/components/filter/CameraGroupSelector.tsx @@ -555,9 +555,7 @@ export function CameraGroupEdit({ message: "Invalid camera group name.", }), - cameras: z.array(z.string()).min(2, { - message: "You must select at least two cameras.", - }), + cameras: z.array(z.string()), icon: z .string() .min(1, { message: "You must select an icon." })