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