Enforce unique ID for Hassio discovery (#36671)

This commit is contained in:
Paulus Schoutsen 2020-06-12 08:38:38 -07:00 committed by GitHub
parent c1cf3679aa
commit e8b16f0dfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ To update, run python3 -m script.hassfest
FLOWS = {}
""".strip()
UNIQUE_ID_IGNORE = {"esphome", "fritzbox", "heos", "huawei_lte"}
UNIQUE_ID_IGNORE = {"huawei_lte", "mqtt", "adguard"}
def validate_integration(config: Config, integration: Integration):
@ -30,17 +30,20 @@ def validate_integration(config: Config, integration: Integration):
)
return
needs_unique_id = integration.domain not in UNIQUE_ID_IGNORE and any(
bool(integration.manifest.get(key))
for keys in DISCOVERY_INTEGRATIONS.values()
for key in keys
config_flow = config_flow_file.read_text()
needs_unique_id = integration.domain not in UNIQUE_ID_IGNORE and (
"async_step_hassio" in config_flow
or any(
bool(integration.manifest.get(key))
for keys in DISCOVERY_INTEGRATIONS.values()
for key in keys
)
)
if not needs_unique_id:
return
config_flow = config_flow_file.read_text()
has_unique_id = (
"self.async_set_unique_id" in config_flow
or "config_entry_flow.register_discovery_flow" in config_flow