diff --git a/homeassistant/components/goalzero/config_flow.py b/homeassistant/components/goalzero/config_flow.py index eb38e8fa154..dabe642b658 100644 --- a/homeassistant/components/goalzero/config_flow.py +++ b/homeassistant/components/goalzero/config_flow.py @@ -24,22 +24,20 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN): VERSION = 1 - def __init__(self) -> None: - """Initialize a Goal Zero Yeti flow.""" - self.ip_address: str | None = None + _discovered_ip: str async def async_step_dhcp( self, discovery_info: dhcp.DhcpServiceInfo ) -> ConfigFlowResult: """Handle dhcp discovery.""" - self.ip_address = discovery_info.ip await self.async_set_unique_id(format_mac(discovery_info.macaddress)) - self._abort_if_unique_id_configured(updates={CONF_HOST: self.ip_address}) - self._async_abort_entries_match({CONF_HOST: self.ip_address}) + self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.ip}) + self._async_abort_entries_match({CONF_HOST: discovery_info.ip}) - _, error = await self._async_try_connect(str(self.ip_address)) + _, error = await self._async_try_connect(discovery_info.ip) if error is None: + self._discovered_ip = discovery_info.ip return await self.async_step_confirm_discovery() return self.async_abort(reason=error) @@ -51,7 +49,7 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN): return self.async_create_entry( title=MANUFACTURER, data={ - CONF_HOST: self.ip_address, + CONF_HOST: self._discovered_ip, CONF_NAME: DEFAULT_NAME, }, ) @@ -60,7 +58,7 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN): return self.async_show_form( step_id="confirm_discovery", description_placeholders={ - CONF_HOST: self.ip_address, + CONF_HOST: self._discovered_ip, CONF_NAME: DEFAULT_NAME, }, )