From c3109f808c6da0efad261907330045b200d36704 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Mon, 20 Sep 2021 18:59:16 -0500 Subject: [PATCH] allow partial days in retention settings --- frigate/config.py | 6 +++--- frigate/test/test_config.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frigate/config.py b/frigate/config.py index 6144613d4..fcafb394f 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -66,8 +66,8 @@ class MqttConfig(FrigateBaseModel): class RetainConfig(FrigateBaseModel): - default: int = Field(default=10, title="Default retention period.") - objects: Dict[str, int] = Field( + default: float = Field(default=10, title="Default retention period.") + objects: Dict[str, float] = Field( default_factory=dict, title="Object retention period." ) @@ -90,7 +90,7 @@ class EventsConfig(FrigateBaseModel): class RecordConfig(FrigateBaseModel): enabled: bool = Field(default=False, title="Enable record on all cameras.") - retain_days: int = Field(default=0, title="Recording retention period in days.") + retain_days: float = Field(default=0, title="Recording retention period in days.") events: EventsConfig = Field( default_factory=EventsConfig, title="Event specific settings." ) diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py index bf10f6ae4..523291cf8 100644 --- a/frigate/test/test_config.py +++ b/frigate/test/test_config.py @@ -1107,6 +1107,30 @@ class TestConfig(unittest.TestCase): assert runtime_config.cameras["back"].timestamp_style.position == "bl" assert runtime_config.cameras["back"].timestamp_style.thickness == 4 + def test_allow_retain_to_be_a_decimal(self): + + config = { + "mqtt": {"host": "mqtt"}, + "snapshots": {"retain": {"default": 1.5}}, + "cameras": { + "back": { + "ffmpeg": { + "inputs": [ + { + "path": "rtsp://10.0.0.1:554/video", + "roles": ["detect"], + }, + ] + }, + } + }, + } + frigate_config = FrigateConfig(**config) + assert config == frigate_config.dict(exclude_unset=True) + + runtime_config = frigate_config.runtime_config + assert runtime_config.cameras["back"].snapshots.retain.default == 1.5 + if __name__ == "__main__": unittest.main(verbosity=2)