mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use _get_reauth/reconfigure_entry in pyload (#127304)
This commit is contained in:
parent
409d7b3652
commit
2e225dfc3a
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp import CookieJar
|
from aiohttp import CookieJar
|
||||||
from pyloadapi.api import PyLoadAPI
|
from pyloadapi.api import PyLoadAPI
|
||||||
@ -101,7 +101,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a config flow for pyLoad."""
|
"""Handle a config flow for pyLoad."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
config_entry: PyLoadConfigEntry | None
|
config_entry: PyLoadConfigEntry
|
||||||
|
|
||||||
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
|
||||||
@ -156,9 +156,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self.config_entry = self.hass.config_entries.async_get_entry(
|
self.config_entry = self._get_reauth_entry()
|
||||||
self.context["entry_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(
|
||||||
@ -167,9 +165,6 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
assert self.config_entry
|
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
new_input = self.config_entry.data | user_input
|
new_input = self.config_entry.data | user_input
|
||||||
try:
|
try:
|
||||||
@ -204,9 +199,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform a reconfiguration."""
|
"""Perform a reconfiguration."""
|
||||||
self.config_entry = self.hass.config_entries.async_get_entry(
|
self.config_entry = self._get_reconfigure_entry()
|
||||||
self.context["entry_id"]
|
|
||||||
)
|
|
||||||
return await self.async_step_reconfigure_confirm()
|
return await self.async_step_reconfigure_confirm()
|
||||||
|
|
||||||
async def async_step_reconfigure_confirm(
|
async def async_step_reconfigure_confirm(
|
||||||
@ -215,9 +208,6 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle the reconfiguration flow."""
|
"""Handle the reconfiguration flow."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
assert self.config_entry
|
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
try:
|
try:
|
||||||
await validate_input(self.hass, user_input)
|
await validate_input(self.hass, user_input)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user