mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Store ezviz flow data in flow handler attributes (#127171)
This commit is contained in:
parent
46480c5624
commit
36df9e0464
@ -93,6 +93,10 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
|
ip_address: str
|
||||||
|
username: str | None
|
||||||
|
password: str | None
|
||||||
|
|
||||||
async def _validate_and_create_camera_rtsp(self, data: dict) -> ConfigFlowResult:
|
async def _validate_and_create_camera_rtsp(self, data: dict) -> ConfigFlowResult:
|
||||||
"""Try DESCRIBE on RTSP camera with credentials."""
|
"""Try DESCRIBE on RTSP camera with credentials."""
|
||||||
|
|
||||||
@ -166,10 +170,8 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
if user_input[CONF_URL] == CONF_CUSTOMIZE:
|
if user_input[CONF_URL] == CONF_CUSTOMIZE:
|
||||||
self.context["data"] = {
|
self.username = user_input[CONF_USERNAME]
|
||||||
CONF_USERNAME: user_input[CONF_USERNAME],
|
self.password = user_input[CONF_PASSWORD]
|
||||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
|
||||||
}
|
|
||||||
return await self.async_step_user_custom_url()
|
return await self.async_step_user_custom_url()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -222,8 +224,8 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
auth_data = {}
|
auth_data = {}
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
user_input[CONF_USERNAME] = self.context["data"][CONF_USERNAME]
|
user_input[CONF_USERNAME] = self.username
|
||||||
user_input[CONF_PASSWORD] = self.context["data"][CONF_PASSWORD]
|
user_input[CONF_PASSWORD] = self.password
|
||||||
|
|
||||||
try:
|
try:
|
||||||
auth_data = await self.hass.async_add_executor_job(
|
auth_data = await self.hass.async_add_executor_job(
|
||||||
@ -272,7 +274,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
self.context["title_placeholders"] = {ATTR_SERIAL: self.unique_id}
|
self.context["title_placeholders"] = {ATTR_SERIAL: self.unique_id}
|
||||||
self.context["data"] = {CONF_IP_ADDRESS: discovery_info[CONF_IP_ADDRESS]}
|
self.ip_address = discovery_info[CONF_IP_ADDRESS]
|
||||||
|
|
||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
@ -284,7 +286,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
user_input[ATTR_SERIAL] = self.unique_id
|
user_input[ATTR_SERIAL] = self.unique_id
|
||||||
user_input[CONF_IP_ADDRESS] = self.context["data"][CONF_IP_ADDRESS]
|
user_input[CONF_IP_ADDRESS] = self.ip_address
|
||||||
try:
|
try:
|
||||||
return await self._validate_and_create_camera_rtsp(user_input)
|
return await self._validate_and_create_camera_rtsp(user_input)
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors=errors,
|
errors=errors,
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
ATTR_SERIAL: self.unique_id,
|
ATTR_SERIAL: self.unique_id,
|
||||||
CONF_IP_ADDRESS: self.context["data"][CONF_IP_ADDRESS],
|
CONF_IP_ADDRESS: self.ip_address,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user