1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-27 14:31:13 +00:00

Integrations v2.1: Differentiating hubs, devices and services (#80524)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Franck Nijhof
2022-10-19 12:41:43 +02:00
committed by GitHub
parent 0c8884fd51
commit c4bbc439a5
11 changed files with 1376 additions and 105 deletions

View File

@@ -86,7 +86,10 @@ def _generate_and_validate(integrations: dict[str, Integration], config: Config)
_validate_integration(config, integration)
domains[integration.integration_type].append(domain)
if integration.integration_type == "helper":
domains["helper"].append(domain)
else:
domains["integration"].append(domain)
return black.format_str(BASE.format(to_string(domains)), mode=black.Mode())
@@ -106,6 +109,7 @@ def _populate_brand_integrations(
metadata = {}
metadata["config_flow"] = integration.config_flow
metadata["iot_class"] = integration.iot_class
metadata["integration_type"] = integration.integration_type
if integration.translated_name:
integration_data["translated_name"].add(domain)
else:
@@ -169,11 +173,16 @@ def _generate_integrations(
continue
metadata["config_flow"] = integration.config_flow
metadata["iot_class"] = integration.iot_class
metadata["integration_type"] = integration.integration_type
if integration.translated_name:
result["translated_name"].add(domain)
else:
metadata["name"] = integration.name
result[integration.integration_type][domain] = metadata
if integration.integration_type == "helper":
result["helper"][domain] = metadata
else:
result["integration"][domain] = metadata
return json.dumps(
result | {"translated_name": sorted(result["translated_name"])}, indent=2

View File

@@ -162,8 +162,16 @@ MANIFEST_SCHEMA = vol.Schema(
{
vol.Required("domain"): str,
vol.Required("name"): str,
vol.Optional("integration_type"): vol.In(
["entity", "hardware", "helper", "system"]
vol.Optional("integration_type", default="hub"): vol.In(
[
"device",
"entity",
"hardware",
"helper",
"hub",
"service",
"system",
]
),
vol.Optional("config_flow"): bool,
vol.Optional("mqtt"): [str],

View File

@@ -177,7 +177,7 @@ class Integration:
@property
def integration_type(self) -> str:
"""Get integration_type."""
return self.manifest.get("integration_type", "integration")
return self.manifest.get("integration_type", "hub")
@property
def iot_class(self) -> str | None: