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
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT
|
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_CODE,
|
ATTR_CODE,
|
||||||
CONF_CODE,
|
CONF_CODE,
|
||||||
@ -365,8 +365,7 @@ async def async_unload_entry(hass, entry):
|
|||||||
|
|
||||||
async def async_update_options(hass, config_entry):
|
async def async_update_options(hass, config_entry):
|
||||||
"""Handle an options update."""
|
"""Handle an options update."""
|
||||||
simplisafe = hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id]
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
simplisafe.options = config_entry.options
|
|
||||||
|
|
||||||
|
|
||||||
class SimpliSafeWebsocket:
|
class SimpliSafeWebsocket:
|
||||||
@ -530,17 +529,26 @@ class SimpliSafe:
|
|||||||
for result in results:
|
for result in results:
|
||||||
if isinstance(result, InvalidCredentialsError):
|
if isinstance(result, InvalidCredentialsError):
|
||||||
if self._emergency_refresh_token_used:
|
if self._emergency_refresh_token_used:
|
||||||
LOGGER.error(
|
matching_flows = [
|
||||||
"Token disconnected or invalid. Please re-auth the "
|
flow
|
||||||
"SimpliSafe integration in HASS"
|
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.async_create_task(
|
||||||
self._hass.config_entries.flow.async_init(
|
self._hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth"},
|
context={
|
||||||
|
"source": SOURCE_REAUTH,
|
||||||
|
"unique_id": self._config_entry.unique_id,
|
||||||
|
},
|
||||||
data=self._config_entry.data,
|
data=self._config_entry.data,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
LOGGER.warning("SimpliSafe cloud error; trying stored refresh token")
|
LOGGER.warning("SimpliSafe cloud error; trying stored refresh token")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user