From 512a474e934798c0bd2bdf5860bf5a56956045e5 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 16 Aug 2021 07:28:26 -0700 Subject: [PATCH] Allow specifying discovery without a config flow (#54677) --- .../components/rainforest_eagle/manifest.json | 7 +++- script/hassfest/config_flow.py | 37 +------------------ script/hassfest/dhcp.py | 2 +- script/hassfest/model.py | 5 +++ script/hassfest/mqtt.py | 2 +- script/hassfest/ssdp.py | 2 +- script/hassfest/zeroconf.py | 2 +- 7 files changed, 16 insertions(+), 41 deletions(-) diff --git a/homeassistant/components/rainforest_eagle/manifest.json b/homeassistant/components/rainforest_eagle/manifest.json index fd28e5b0994..4b6268fd59a 100644 --- a/homeassistant/components/rainforest_eagle/manifest.json +++ b/homeassistant/components/rainforest_eagle/manifest.json @@ -4,5 +4,10 @@ "documentation": "https://www.home-assistant.io/integrations/rainforest_eagle", "requirements": ["eagle200_reader==0.2.4", "uEagle==0.0.2"], "codeowners": ["@gtdiehl", "@jcalbert"], - "iot_class": "local_polling" + "iot_class": "local_polling", + "dhcp": [ + { + "macaddress": "D8D5B9*" + } + ] } diff --git a/script/hassfest/config_flow.py b/script/hassfest/config_flow.py index e4d1be7bc46..8e0f53fd736 100644 --- a/script/hassfest/config_flow.py +++ b/script/hassfest/config_flow.py @@ -29,31 +29,6 @@ def validate_integration(config: Config, integration: Integration): "config_flow", "Config flows need to be defined in the file config_flow.py", ) - if integration.manifest.get("homekit"): - integration.add_error( - "config_flow", - "HomeKit information in a manifest requires a config flow to exist", - ) - if integration.manifest.get("mqtt"): - integration.add_error( - "config_flow", - "MQTT information in a manifest requires a config flow to exist", - ) - if integration.manifest.get("ssdp"): - integration.add_error( - "config_flow", - "SSDP information in a manifest requires a config flow to exist", - ) - if integration.manifest.get("zeroconf"): - integration.add_error( - "config_flow", - "Zeroconf information in a manifest requires a config flow to exist", - ) - if integration.manifest.get("dhcp"): - integration.add_error( - "config_flow", - "DHCP information in a manifest requires a config flow to exist", - ) return config_flow = config_flow_file.read_text() @@ -98,17 +73,7 @@ def generate_and_validate(integrations: dict[str, Integration], config: Config): for domain in sorted(integrations): integration = integrations[domain] - if not integration.manifest: - continue - - if not ( - integration.manifest.get("config_flow") - or integration.manifest.get("homekit") - or integration.manifest.get("mqtt") - or integration.manifest.get("ssdp") - or integration.manifest.get("zeroconf") - or integration.manifest.get("dhcp") - ): + if not integration.manifest or not integration.config_flow: continue validate_integration(config, integration) diff --git a/script/hassfest/dhcp.py b/script/hassfest/dhcp.py index a3abe80063e..c746c64e46f 100644 --- a/script/hassfest/dhcp.py +++ b/script/hassfest/dhcp.py @@ -24,7 +24,7 @@ def generate_and_validate(integrations: list[dict[str, str]]): for domain in sorted(integrations): integration = integrations[domain] - if not integration.manifest: + if not integration.manifest or not integration.config_flow: continue match_types = integration.manifest.get("dhcp", []) diff --git a/script/hassfest/model.py b/script/hassfest/model.py index b20df6ea42f..69810686cc1 100644 --- a/script/hassfest/model.py +++ b/script/hassfest/model.py @@ -96,6 +96,11 @@ class Integration: """Return quality scale of the integration.""" return self.manifest.get("quality_scale") + @property + def config_flow(self) -> str: + """Return if the integration has a config flow.""" + return self.manifest.get("config_flow") + @property def requirements(self) -> list[str]: """List of requirements.""" diff --git a/script/hassfest/mqtt.py b/script/hassfest/mqtt.py index 718df4ac827..f325518d7b9 100644 --- a/script/hassfest/mqtt.py +++ b/script/hassfest/mqtt.py @@ -26,7 +26,7 @@ def generate_and_validate(integrations: dict[str, Integration]): for domain in sorted(integrations): integration = integrations[domain] - if not integration.manifest: + if not integration.manifest or not integration.config_flow: continue mqtt = integration.manifest.get("mqtt") diff --git a/script/hassfest/ssdp.py b/script/hassfest/ssdp.py index c71d5432adf..0611f9a2225 100644 --- a/script/hassfest/ssdp.py +++ b/script/hassfest/ssdp.py @@ -31,7 +31,7 @@ def generate_and_validate(integrations: dict[str, Integration]): for domain in sorted(integrations): integration = integrations[domain] - if not integration.manifest: + if not integration.manifest or not integration.config_flow: continue ssdp = integration.manifest.get("ssdp") diff --git a/script/hassfest/zeroconf.py b/script/hassfest/zeroconf.py index 907c6aaceff..4ce4896952e 100644 --- a/script/hassfest/zeroconf.py +++ b/script/hassfest/zeroconf.py @@ -28,7 +28,7 @@ def generate_and_validate(integrations: dict[str, Integration]): for domain in sorted(integrations): integration = integrations[domain] - if not integration.manifest: + if not integration.manifest or not integration.config_flow: continue service_types = integration.manifest.get("zeroconf", [])