mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix SimpliSafe re-auth flow (#41805)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
06b99a1ff9
commit
efffc82414
@ -16,7 +16,7 @@ from simplipy.websocket import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH
|
||||
from homeassistant.const import (
|
||||
ATTR_CODE,
|
||||
CONF_CODE,
|
||||
@ -365,8 +365,7 @@ async def async_unload_entry(hass, entry):
|
||||
|
||||
async def async_update_options(hass, config_entry):
|
||||
"""Handle an options update."""
|
||||
simplisafe = hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id]
|
||||
simplisafe.options = config_entry.options
|
||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||
|
||||
|
||||
class SimpliSafeWebsocket:
|
||||
@ -530,17 +529,26 @@ class SimpliSafe:
|
||||
for result in results:
|
||||
if isinstance(result, InvalidCredentialsError):
|
||||
if self._emergency_refresh_token_used:
|
||||
LOGGER.error(
|
||||
"Token disconnected or invalid. Please re-auth the "
|
||||
"SimpliSafe integration in HASS"
|
||||
)
|
||||
self._hass.async_create_task(
|
||||
self._hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": "reauth"},
|
||||
data=self._config_entry.data,
|
||||
matching_flows = [
|
||||
flow
|
||||
for flow in self._hass.config_entries.flow.async_progress()
|
||||
if flow["context"].get("source") == SOURCE_REAUTH
|
||||
and flow["context"].get("unique_id")
|
||||
== self._config_entry.unique_id
|
||||
]
|
||||
|
||||
if not matching_flows:
|
||||
self._hass.async_create_task(
|
||||
self._hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"unique_id": self._config_entry.unique_id,
|
||||
},
|
||||
data=self._config_entry.data,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
LOGGER.warning("SimpliSafe cloud error; trying stored refresh token")
|
||||
|
Loading…
x
Reference in New Issue
Block a user