Adjust async_step_reauth in isy994 (#74169)
parent
306486edfd
commit
9c991d9c6f
|
@ -13,10 +13,11 @@ from pyisy.configuration import Configuration
|
|||
from pyisy.connection import Connection
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, data_entry_flow, exceptions
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.components import dhcp, ssdp
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import AbortFlow, FlowResult
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import (
|
||||
|
@ -132,7 +133,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> data_entry_flow.FlowResult:
|
||||
) -> FlowResult:
|
||||
"""Handle the initial step."""
|
||||
errors = {}
|
||||
info: dict[str, str] = {}
|
||||
|
@ -160,9 +161,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_import(
|
||||
self, user_input: dict[str, Any]
|
||||
) -> data_entry_flow.FlowResult:
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
|
||||
"""Handle import."""
|
||||
return await self.async_step_user(user_input)
|
||||
|
||||
|
@ -174,7 +173,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
if not existing_entry:
|
||||
return
|
||||
if existing_entry.source == config_entries.SOURCE_IGNORE:
|
||||
raise data_entry_flow.AbortFlow("already_configured")
|
||||
raise AbortFlow("already_configured")
|
||||
parsed_url = urlparse(existing_entry.data[CONF_HOST])
|
||||
if parsed_url.hostname != ip_address:
|
||||
new_netloc = ip_address
|
||||
|
@ -198,11 +197,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
),
|
||||
},
|
||||
)
|
||||
raise data_entry_flow.AbortFlow("already_configured")
|
||||
raise AbortFlow("already_configured")
|
||||
|
||||
async def async_step_dhcp(
|
||||
self, discovery_info: dhcp.DhcpServiceInfo
|
||||
) -> data_entry_flow.FlowResult:
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
"""Handle a discovered isy994 via dhcp."""
|
||||
friendly_name = discovery_info.hostname
|
||||
if friendly_name.startswith("polisy"):
|
||||
|
@ -223,9 +220,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self.context["title_placeholders"] = self.discovered_conf
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> data_entry_flow.FlowResult:
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
"""Handle a discovered isy994."""
|
||||
friendly_name = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]
|
||||
url = discovery_info.ssdp_location
|
||||
|
@ -254,16 +249,14 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self.context["title_placeholders"] = self.discovered_conf
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_step_reauth(
|
||||
self, data: Mapping[str, Any]
|
||||
) -> data_entry_flow.FlowResult:
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
"""Handle reauth."""
|
||||
self._existing_entry = await self.async_set_unique_id(self.context["unique_id"])
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> data_entry_flow.FlowResult:
|
||||
) -> FlowResult:
|
||||
"""Handle reauth input."""
|
||||
errors = {}
|
||||
assert self._existing_entry is not None
|
||||
|
@ -315,7 +308,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> data_entry_flow.FlowResult:
|
||||
) -> FlowResult:
|
||||
"""Handle options flow."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="", data=user_input)
|
||||
|
|
Loading…
Reference in New Issue