string or list for camera groups (#11616)

This commit is contained in:
Josh Hawkins 2024-05-29 09:19:05 -05:00 committed by GitHub
parent 6dd9660ecd
commit 3dd401f57a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -1171,12 +1171,20 @@ class LoggerConfig(FrigateBaseModel):
class CameraGroupConfig(FrigateBaseModel): class CameraGroupConfig(FrigateBaseModel):
"""Represents a group of cameras.""" """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." default_factory=list, title="List of cameras in this group."
) )
icon: str = Field(default="generic", title="Icon that represents camera group.") icon: str = Field(default="generic", title="Icon that represents camera group.")
order: int = Field(default=0, title="Sort order for 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: def verify_config_roles(camera_config: CameraConfig) -> None:
"""Verify that roles are setup in the config correctly.""" """Verify that roles are setup in the config correctly."""

View File

@ -555,9 +555,7 @@ export function CameraGroupEdit({
message: "Invalid camera group name.", message: "Invalid camera group name.",
}), }),
cameras: z.array(z.string()).min(2, { cameras: z.array(z.string()),
message: "You must select at least two cameras.",
}),
icon: z icon: z
.string() .string()
.min(1, { message: "You must select an icon." }) .min(1, { message: "You must select an icon." })