IntelliFire DHCP Discovery Patch (#72617)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Jeef 2022-06-29 11:01:18 -06:00 committed by GitHub
parent 0a65f53356
commit d6e9118f36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 7 deletions

View file

@ -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)

View file

@ -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"],

View file

@ -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

View file

@ -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