From d6e9118f36ff43055b2148744b304a5208398496 Mon Sep 17 00:00:00 2001 From: Jeef Date: Wed, 29 Jun 2022 11:01:18 -0600 Subject: [PATCH] IntelliFire DHCP Discovery Patch (#72617) Co-authored-by: J. Nick Koston --- homeassistant/components/intellifire/config_flow.py | 12 ++++++++---- homeassistant/components/intellifire/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/intellifire/config_flow.py b/homeassistant/components/intellifire/config_flow.py index 23bd92b0715..4556668b702 100644 --- a/homeassistant/components/intellifire/config_flow.py +++ b/homeassistant/components/intellifire/config_flow.py @@ -31,15 +31,16 @@ class DiscoveredHostInfo: serial: str | None -async def validate_host_input(host: str) -> str: +async def validate_host_input(host: str, dhcp_mode: bool = False) -> str: """Validate the user input allows us to connect. Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user. """ LOGGER.debug("Instantiating IntellifireAPI with host: [%s]", host) api = IntellifireAPILocal(fireplace_ip=host) - await api.poll() + await api.poll(supress_warnings=dhcp_mode) serial = api.data.serial + LOGGER.debug("Found a fireplace: %s", serial) # Return the serial number which will be used to calculate a unique ID for the device/sensors return serial @@ -240,14 +241,17 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult: """Handle DHCP Discovery.""" - LOGGER.debug("STEP: dhcp") # Run validation logic on ip host = discovery_info.ip + LOGGER.debug("STEP: dhcp for host %s", host) self._async_abort_entries_match({CONF_HOST: host}) try: - self._serial = await validate_host_input(host) + self._serial = await validate_host_input(host, dhcp_mode=True) except (ConnectionError, ClientConnectionError): + LOGGER.debug( + "DHCP Discovery has determined %s is not an IntelliFire device", host + ) return self.async_abort(reason="not_intellifire_device") await self.async_set_unique_id(self._serial) diff --git a/homeassistant/components/intellifire/manifest.json b/homeassistant/components/intellifire/manifest.json index cd1a12a36bf..e2ae4bb8abe 100644 --- a/homeassistant/components/intellifire/manifest.json +++ b/homeassistant/components/intellifire/manifest.json @@ -3,7 +3,7 @@ "name": "IntelliFire", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/intellifire", - "requirements": ["intellifire4py==2.0.0"], + "requirements": ["intellifire4py==2.0.1"], "codeowners": ["@jeeftor"], "iot_class": "local_polling", "loggers": ["intellifire4py"], diff --git a/requirements_all.txt b/requirements_all.txt index 064f686dc49..e67cd8dc3de 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -894,7 +894,7 @@ influxdb==5.3.1 insteon-frontend-home-assistant==0.1.1 # homeassistant.components.intellifire -intellifire4py==2.0.0 +intellifire4py==2.0.1 # homeassistant.components.iotawatt iotawattpy==0.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 94d59b40526..9b9681b38bb 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -637,7 +637,7 @@ influxdb==5.3.1 insteon-frontend-home-assistant==0.1.1 # homeassistant.components.intellifire -intellifire4py==2.0.0 +intellifire4py==2.0.1 # homeassistant.components.iotawatt iotawattpy==0.1.0