Allow integrations to request dhcp discovery flows for registered devices (#66528)
This commit is contained in:
parent
2b43293363
commit
f069a37f7d
7 changed files with 239 additions and 647 deletions
|
@ -1,7 +1,8 @@
|
|||
"""Generate dhcp file."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re
|
||||
|
||||
from .model import Config, Integration
|
||||
|
||||
|
@ -10,10 +11,11 @@ BASE = """
|
|||
|
||||
To update, run python3 -m script.hassfest
|
||||
\"\"\"
|
||||
from __future__ import annotations
|
||||
|
||||
# fmt: off
|
||||
|
||||
DHCP = {}
|
||||
DHCP: list[dict[str, str | bool]] = {}
|
||||
""".strip()
|
||||
|
||||
|
||||
|
@ -35,7 +37,14 @@ def generate_and_validate(integrations: list[dict[str, str]]):
|
|||
for entry in match_types:
|
||||
match_list.append({"domain": domain, **entry})
|
||||
|
||||
return BASE.format(json.dumps(match_list, indent=4))
|
||||
# JSON will format `True` as `true`
|
||||
# re.sub for flake8 E128
|
||||
formatted = pprint.pformat(match_list)
|
||||
formatted_aligned_continuation = re.sub(r"^\[\{", "[\n {", formatted)
|
||||
formatted_align_indent = re.sub(
|
||||
r"(?m)^ ", " ", formatted_aligned_continuation, flags=re.MULTILINE, count=0
|
||||
)
|
||||
return BASE.format(formatted_align_indent)
|
||||
|
||||
|
||||
def validate(integrations: dict[str, Integration], config: Config):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue