|
13 | 13 |
|
14 | 14 | logger = logging.getLogger(__name__)
|
15 | 15 |
|
16 |
| -CURRENT_CONFIG_VERSION = "0.15-0" |
| 16 | +CURRENT_CONFIG_VERSION = "0.16-0" |
17 | 17 |
|
18 | 18 |
|
19 | 19 | def migrate_frigate_config(config_file: str):
|
@@ -67,6 +67,13 @@ def migrate_frigate_config(config_file: str):
|
67 | 67 | yaml.dump(new_config, f)
|
68 | 68 | previous_version = "0.15-0"
|
69 | 69 |
|
| 70 | + if previous_version < "0.16-0": |
| 71 | + logger.info(f"Migrating frigate config from {previous_version} to 0.16-0...") |
| 72 | + new_config = migrate_016_0(config) |
| 73 | + with open(config_file, "w") as f: |
| 74 | + yaml.dump(new_config, f) |
| 75 | + previous_version = "0.16-0" |
| 76 | + |
70 | 77 | logger.info("Finished frigate config migration...")
|
71 | 78 |
|
72 | 79 |
|
@@ -257,6 +264,29 @@ def migrate_015_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]
|
257 | 264 | return new_config
|
258 | 265 |
|
259 | 266 |
|
| 267 | +def migrate_016_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]: |
| 268 | + """Handle migrating frigate config to 0.16-0""" |
| 269 | + new_config = config.copy() |
| 270 | + |
| 271 | + for name, camera in config.get("cameras", {}).items(): |
| 272 | + camera_config: dict[str, dict[str, any]] = camera.copy() |
| 273 | + |
| 274 | + live_config = camera_config.get("live", {}) |
| 275 | + if "stream_name" in live_config: |
| 276 | + # Migrate from live -> stream_name to live -> streams -> dict |
| 277 | + stream_name = live_config["stream_name"] |
| 278 | + live_config["streams"] = {stream_name: stream_name} |
| 279 | + |
| 280 | + del live_config["stream_name"] |
| 281 | + |
| 282 | + camera_config["live"] = live_config |
| 283 | + |
| 284 | + new_config["cameras"][name] = camera_config |
| 285 | + |
| 286 | + new_config["version"] = "0.16-0" |
| 287 | + return new_config |
| 288 | + |
| 289 | + |
260 | 290 | def get_relative_coordinates(
|
261 | 291 | mask: Optional[Union[str, list]], frame_shape: tuple[int, int]
|
262 | 292 | ) -> Union[str, list]:
|
|
0 commit comments