diff --git a/frigate/config.py b/frigate/config.py index ea6ea3280..66035bcce 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -332,9 +332,15 @@ class FfmpegConfig(BaseModel): ) +class CameraRoleEnum(str, Enum): + record = "record" + rtmp = "rtmp" + detect = "detect" + + class CameraInput(BaseModel): path: str = Field(title="Camera input path.") - roles: List[str] = Field(title="Roles assigned to this input.") + roles: List[CameraRoleEnum] = Field(title="Roles assigned to this input.") global_args: Union[str, List[str]] = Field( default_factory=list, title="FFmpeg global arguments." ) diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py index 20fda3a05..20cab822e 100644 --- a/frigate/test/test_config.py +++ b/frigate/test/test_config.py @@ -32,8 +32,8 @@ class TestConfig(unittest.TestCase): assert self.minimal == frigate_config.dict(exclude_unset=True) runtime_config = frigate_config.runtime_config - assert "coral" in runtime_config.detectors.keys() - assert runtime_config.detectors["coral"].type == DetectorTypeEnum.edgetpu + assert "cpu" in runtime_config.detectors.keys() + assert runtime_config.detectors["cpu"].type == DetectorTypeEnum.cpu def test_invalid_mqtt_config(self): config = { @@ -692,6 +692,31 @@ class TestConfig(unittest.TestCase): runtime_config = frigate_config.runtime_config assert runtime_config.model.merged_labelmap[0] == "person" + def test_fails_on_invalid_role(self): + + config = { + "mqtt": {"host": "mqtt"}, + "cameras": { + "back": { + "ffmpeg": { + "inputs": [ + { + "path": "rtsp://10.0.0.1:554/video", + "roles": ["detect", "clips"], + }, + ] + }, + "detect": { + "height": 1080, + "width": 1920, + "fps": 5, + }, + } + }, + } + + self.assertRaises(ValidationError, lambda: FrigateConfig(**config)) + if __name__ == "__main__": unittest.main(verbosity=2)