mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Use _get_reauth/reconfigure_entry in shelly (#127308)
This commit is contained in:
parent
fac3d575c9
commit
9219339762
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from typing import TYPE_CHECKING, Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from aioshelly.block_device import BlockDevice
|
from aioshelly.block_device import BlockDevice
|
||||||
from aioshelly.common import ConnectionOptions, get_info
|
from aioshelly.common import ConnectionOptions, get_info
|
||||||
@ -146,7 +146,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
port: int = DEFAULT_HTTP_PORT
|
port: int = DEFAULT_HTTP_PORT
|
||||||
info: dict[str, Any] = {}
|
info: dict[str, Any] = {}
|
||||||
device_info: dict[str, Any] = {}
|
device_info: dict[str, Any] = {}
|
||||||
entry: ConfigEntry | None = None
|
entry: ConfigEntry
|
||||||
|
|
||||||
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
|
||||||
@ -356,7 +356,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.entry = self._get_reauth_entry()
|
||||||
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(
|
||||||
@ -364,7 +364,6 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
assert self.entry is not None
|
|
||||||
host = self.entry.data[CONF_HOST]
|
host = self.entry.data[CONF_HOST]
|
||||||
port = get_http_port(self.entry.data)
|
port = get_http_port(self.entry.data)
|
||||||
|
|
||||||
@ -403,14 +402,9 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self.host = entry_data[CONF_HOST]
|
||||||
|
self.port = entry_data.get(CONF_PORT, DEFAULT_HTTP_PORT)
|
||||||
if TYPE_CHECKING:
|
self.entry = self._get_reconfigure_entry()
|
||||||
assert entry is not None
|
|
||||||
|
|
||||||
self.host = entry.data[CONF_HOST]
|
|
||||||
self.port = entry.data.get(CONF_PORT, DEFAULT_HTTP_PORT)
|
|
||||||
self.entry = entry
|
|
||||||
|
|
||||||
return await self.async_step_reconfigure_confirm()
|
return await self.async_step_reconfigure_confirm()
|
||||||
|
|
||||||
@ -420,9 +414,6 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
assert self.entry is not None
|
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
host = user_input[CONF_HOST]
|
host = user_input[CONF_HOST]
|
||||||
port = user_input.get(CONF_PORT, DEFAULT_HTTP_PORT)
|
port = user_input.get(CONF_PORT, DEFAULT_HTTP_PORT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user