Skip to content

Commit a402139

Browse files
committed
configuration["discovery_filter"] fix test for Docker & HA Add-on
This will need testing and verification with the Docker image and HA Add-on. The HA Add-on also converts identities to a whole string, which Docker keeps it as a dictionary, same for bindkeys. Would and should it not be possible and preferable to make any such type format conversions, if and when required, in the projects themselves, so that the underlying config file can be assumed to be identical across all incarnations of Theengs Gateway?
1 parent d3867fc commit a402139

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)