mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Adjust type hints in goalzero config_flow (#127270)
This commit is contained in:
parent
f24523e93b
commit
7994729742
@ -24,22 +24,20 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
def __init__(self) -> None:
|
_discovered_ip: str
|
||||||
"""Initialize a Goal Zero Yeti flow."""
|
|
||||||
self.ip_address: str | None = None
|
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: dhcp.DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery."""
|
"""Handle dhcp discovery."""
|
||||||
self.ip_address = discovery_info.ip
|
|
||||||
|
|
||||||
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
||||||
self._abort_if_unique_id_configured(updates={CONF_HOST: self.ip_address})
|
self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.ip})
|
||||||
self._async_abort_entries_match({CONF_HOST: self.ip_address})
|
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:
|
if error is None:
|
||||||
|
self._discovered_ip = discovery_info.ip
|
||||||
return await self.async_step_confirm_discovery()
|
return await self.async_step_confirm_discovery()
|
||||||
return self.async_abort(reason=error)
|
return self.async_abort(reason=error)
|
||||||
|
|
||||||
@ -51,7 +49,7 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=MANUFACTURER,
|
title=MANUFACTURER,
|
||||||
data={
|
data={
|
||||||
CONF_HOST: self.ip_address,
|
CONF_HOST: self._discovered_ip,
|
||||||
CONF_NAME: DEFAULT_NAME,
|
CONF_NAME: DEFAULT_NAME,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -60,7 +58,7 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="confirm_discovery",
|
step_id="confirm_discovery",
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
CONF_HOST: self.ip_address,
|
CONF_HOST: self._discovered_ip,
|
||||||
CONF_NAME: DEFAULT_NAME,
|
CONF_NAME: DEFAULT_NAME,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user