1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Refactor zeroconf task handling (#88204)

* Refactor zeroconf task handling

- Avoid the need to create tasks for most callbacks
- Fixes the untracked task that could get unexpectedly GCed

* be consistant

* be consistant

* fix zeroconf tests

* runtime

* Revert "runtime"

This reverts commit 19e6b61837.

* precalc

* refactor

* tweak

* update tests
This commit is contained in:
J. Nick Koston
2023-02-15 20:44:11 -06:00
committed by GitHub
parent c0e22be7a8
commit c83ea297b5
6 changed files with 346 additions and 112 deletions

View File

@@ -3,7 +3,10 @@ from __future__ import annotations
from collections import defaultdict
from homeassistant.loader import async_process_zeroconf_match_dict
from homeassistant.loader import (
async_process_zeroconf_match_dict,
homekit_always_discover,
)
from .model import Config, Integration
from .serializer import format_python_namespace
@@ -12,7 +15,7 @@ from .serializer import format_python_namespace
def generate_and_validate(integrations: dict[str, Integration]) -> str:
"""Validate and generate zeroconf data."""
service_type_dict = defaultdict(list)
homekit_dict: dict[str, str] = {}
homekit_dict: dict[str, dict[str, str]] = {}
for domain in sorted(integrations):
integration = integrations[domain]
@@ -42,7 +45,12 @@ def generate_and_validate(integrations: dict[str, Integration]) -> str:
)
break
homekit_dict[model] = domain
homekit_dict[model] = {
"domain": domain,
"always_discover": homekit_always_discover(
integration.manifest["iot_class"]
),
}
# HomeKit models are matched on starting string, make sure none overlap.
warned = set()