Adjust type hints in goalzero config_flow (#127270)

pull/127333/head
epenet 2024-10-02 14:26:26 +02:00 committed by GitHub
parent f24523e93b
commit 7994729742
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 9 deletions

View File

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