Skip to content

Commit 0436b14

Browse files
authored
Merge pull request #1515 from bal0o/master
Fix headless argument handling HACS Integration
2 parents 41f6f3d + ac459aa commit 0436b14

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

custom_components/uk_bin_collection/__init__.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,28 @@ def build_ukbcd_args(config_data: dict) -> list:
283283
"""Build the argument list for UKBinCollectionApp from config data."""
284284
council = config_data.get("original_parser") or config_data.get("council", "")
285285
url = config_data.get("url", "")
286-
287286
args = [council, url]
288287

288+
# Per-key formatters: return a list of CLI args for that key
289+
def _format_headless(v):
290+
return ["--headless"] if v else ["--not-headless"]
291+
292+
def _format_web_driver(v):
293+
return [f"--web_driver={v.rstrip('/')}"] if v is not None else []
294+
295+
formatters = {
296+
"headless": _format_headless,
297+
"web_driver": _format_web_driver,
298+
}
299+
289300
for key, value in config_data.items():
290301
if key in EXCLUDED_ARG_KEYS:
291302
continue
292-
if key == "web_driver" and value is not None:
293-
value = value.rstrip("/")
294-
args.append(f"--{key}={value}")
303+
fmt = formatters.get(key)
304+
if fmt:
305+
args.extend(fmt(value))
306+
else:
307+
args.append(f"--{key}={value}")
295308

296309
return args
297310

custom_components/uk_bin_collection/const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"council",
3232
"url",
3333
"skip_get_url",
34-
"headless",
3534
"local_browser",
3635
"timeout",
3736
"icon_color_mapping",

0 commit comments

Comments
 (0)