SSDP matching improvements (#28285)

* SSDP matching improvements

- support multiple match groups per domain
- require matches on all, not any item in a group
- support matching on all UPnP device description data

* Manifest structure fixes
This commit is contained in:
Ville Skyttä authored and Paulus Schoutsen committed 2019-11-02 12:30:09 -07:00
1 parent a8dff2f2d0
commit 1679ec3245
10 files changed
+113 -92

No files matched your search

+1 -5
View File
@@ -14,11 +14,7 @@ MANIFEST_SCHEMA = vol.Schema(
vol.Optional("config_flow"): bool,
vol.Optional("zeroconf"): [str],
vol.Optional("ssdp"): vol.Schema(
{
vol.Optional("st"): [str],
vol.Optional("manufacturer"): [str],
vol.Optional("device_type"): [str],
}
vol.All([vol.All(vol.Schema({}, extra=vol.ALLOW_EXTRA), vol.Length(min=1))])
),
vol.Optional("homekit"): vol.Schema({vol.Optional("models"): [str]}),
vol.Required("documentation"): str,
+4 -12
View File
@@ -24,11 +24,8 @@ def sort_dict(value):
def generate_and_validate(integrations: Dict[str, Integration]):
"""Validate and generate ssdp data."""
data = {
"st": defaultdict(list),
"manufacturer": defaultdict(list),
"device_type": defaultdict(list),
}
data = defaultdict(list)
for domain in sorted(integrations):
integration = integrations[domain]
@@ -56,14 +53,9 @@ def generate_and_validate(integrations: Dict[str, Integration]):
)
continue
for key in "st", "manufacturer", "device_type":
if key not in ssdp:
continue
for matcher in ssdp:
data[domain].append(sort_dict(matcher))
for value in ssdp[key]:
data[key][value].append(domain)
data = sort_dict({key: sort_dict(value) for key, value in data.items()})
return BASE.format(json.dumps(data, indent=4))