mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix inability to erase SimpliSafe code (#44137)
This commit is contained in:
parent
8d9fd93dc7
commit
0696724506
@ -15,6 +15,15 @@ from homeassistant.helpers import aiohttp_client
|
|||||||
from . import async_get_client_id
|
from . import async_get_client_id
|
||||||
from .const import DOMAIN, LOGGER # pylint: disable=unused-import
|
from .const import DOMAIN, LOGGER # pylint: disable=unused-import
|
||||||
|
|
||||||
|
FULL_DATA_SCHEMA = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(CONF_USERNAME): str,
|
||||||
|
vol.Required(CONF_PASSWORD): str,
|
||||||
|
vol.Optional(CONF_CODE): str,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
PASSWORD_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
||||||
|
|
||||||
|
|
||||||
class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a SimpliSafe config flow."""
|
"""Handle a SimpliSafe config flow."""
|
||||||
@ -24,15 +33,6 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
self.full_data_schema = vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Required(CONF_USERNAME): str,
|
|
||||||
vol.Required(CONF_PASSWORD): str,
|
|
||||||
vol.Optional(CONF_CODE): str,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
self.password_data_schema = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
|
||||||
|
|
||||||
self._code = None
|
self._code = None
|
||||||
self._password = None
|
self._password = None
|
||||||
self._username = None
|
self._username = None
|
||||||
@ -125,21 +125,19 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle re-auth completion."""
|
"""Handle re-auth completion."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reauth_confirm", data_schema=self.password_data_schema
|
step_id="reauth_confirm", data_schema=PASSWORD_DATA_SCHEMA
|
||||||
)
|
)
|
||||||
|
|
||||||
self._password = user_input[CONF_PASSWORD]
|
self._password = user_input[CONF_PASSWORD]
|
||||||
|
|
||||||
return await self._async_login_during_step(
|
return await self._async_login_during_step(
|
||||||
step_id="reauth_confirm", form_schema=self.password_data_schema
|
step_id="reauth_confirm", form_schema=PASSWORD_DATA_SCHEMA
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(self, user_input=None):
|
||||||
"""Handle the start of the config flow."""
|
"""Handle the start of the config flow."""
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(
|
return self.async_show_form(step_id="user", data_schema=FULL_DATA_SCHEMA)
|
||||||
step_id="user", data_schema=self.full_data_schema
|
|
||||||
)
|
|
||||||
|
|
||||||
await self.async_set_unique_id(user_input[CONF_USERNAME])
|
await self.async_set_unique_id(user_input[CONF_USERNAME])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
@ -149,7 +147,7 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._username = user_input[CONF_USERNAME]
|
self._username = user_input[CONF_USERNAME]
|
||||||
|
|
||||||
return await self._async_login_during_step(
|
return await self._async_login_during_step(
|
||||||
step_id="user", form_schema=self.full_data_schema
|
step_id="user", form_schema=FULL_DATA_SCHEMA
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -171,7 +169,9 @@ class SimpliSafeOptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
{
|
{
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_CODE,
|
CONF_CODE,
|
||||||
default=self.config_entry.options.get(CONF_CODE),
|
description={
|
||||||
|
"suggested_value": self.config_entry.options.get(CONF_CODE)
|
||||||
|
},
|
||||||
): str
|
): str
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user