Constrain SimpliSafe's check for emergency token usage (#31214)

This commit is contained in:
Aaron Bach 2020-01-27 10:50:16 -07:00 committed by GitHub
parent 4e2737bfb7
commit f95a072877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 6 deletions

View File

@ -316,7 +316,6 @@ class SimpliSafe:
"""Update a system."""
try:
await system.update()
latest_event = await system.get_latest_event()
except InvalidCredentialsError:
# SimpliSafe's cloud is a little shaky. At times, a 500 or 502 will
# seemingly harm simplisafe-python's existing access token _and_ refresh
@ -338,7 +337,9 @@ class SimpliSafe:
_LOGGER.warning("SimpliSafe cloud error; trying stored refresh token")
self._emergency_refresh_token_used = True
await self._api.refresh_access_token(self._config_entry.data[CONF_TOKEN])
return await self._api.refresh_access_token(
self._config_entry.data[CONF_TOKEN]
)
except SimplipyError as err:
_LOGGER.error(
'SimpliSafe error while updating "%s": %s', system.address, err
@ -348,7 +349,7 @@ class SimpliSafe:
_LOGGER.error('Unknown error while updating "%s": %s', system.address, err)
return
self.last_event_data[system.system_id] = latest_event
self.last_event_data[system.system_id] = await system.get_latest_event()
# If we've reached this point using an emergency refresh token, we're in the
# clear and we can discard it:

View File

@ -3,7 +3,7 @@
"name": "SimpliSafe",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/simplisafe",
"requirements": ["simplisafe-python==6.0.0"],
"requirements": ["simplisafe-python==6.1.0"],
"dependencies": [],
"codeowners": ["@bachya"]
}

View File

@ -1816,7 +1816,7 @@ simplehound==0.3
simplepush==1.1.4
# homeassistant.components.simplisafe
simplisafe-python==6.0.0
simplisafe-python==6.1.0
# homeassistant.components.sisyphus
sisyphus-control==2.2.1

View File

@ -591,7 +591,7 @@ sentry-sdk==0.13.5
simplehound==0.3
# homeassistant.components.simplisafe
simplisafe-python==6.0.0
simplisafe-python==6.1.0
# homeassistant.components.sleepiq
sleepyq==0.7