Skip to content

Commit 50fd625

Browse files
committed
configuration["discovery_filter"] list write test for Docker & HA Add-on
1 parent d3867fc commit 50fd625

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

TheengsGateway/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ def read_configuration(config_path: Path) -> dict:
311311

312312
def write_configuration(configuration: dict, config_path: Path) -> None:
313313
"""Write a Theengs Gateway configuration to a file."""
314+
# Ensure discovery_filter is a list before writing
315+
if isinstance(configuration.get("discovery_filter"), str):
316+
configuration["discovery_filter"] = configuration["discovery_filter"].strip("[]").split(",")
317+
314318
try:
315319
with config_path.open(encoding="utf-8", mode="w") as config_file:
316320
config_file.write(
@@ -338,5 +342,7 @@ def merge_args_with_config(config: dict, args: argparse.Namespace) -> None:
338342
config[key].extend(
339343
element for element in value if element not in config[key]
340344
)
345+
elif key == "discovery_filter" and isinstance(value, str):
346+
config[key] = value.strip("[]").split(",")
341347
elif key != "config":
342348
config[key] = value

0 commit comments

Comments
 (0)