mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Handle somfy expired token (#25195)
* HANDLE expired token * RENAME constant * FIX typo
This commit is contained in:
parent
21f68b80ea
commit
a012c61762
@ -25,7 +25,7 @@ DEVICES = 'devices'
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)
|
SCAN_INTERVAL = timedelta(seconds=10)
|
||||||
|
|
||||||
DOMAIN = 'somfy'
|
DOMAIN = 'somfy'
|
||||||
|
|
||||||
@ -146,15 +146,16 @@ class SomfyEntity(Entity):
|
|||||||
return bool([c for c in capabilities if c.name == capability])
|
return bool([c for c in capabilities if c.name == capability])
|
||||||
|
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(SCAN_INTERVAL)
|
||||||
async def update_all_devices(hass):
|
async def update_all_devices(hass):
|
||||||
"""Update all the devices."""
|
"""Update all the devices."""
|
||||||
from requests import HTTPError
|
from requests import HTTPError
|
||||||
|
from oauthlib.oauth2 import TokenExpiredError
|
||||||
try:
|
try:
|
||||||
data = hass.data[DOMAIN]
|
data = hass.data[DOMAIN]
|
||||||
data[DEVICES] = await hass.async_add_executor_job(
|
data[DEVICES] = await hass.async_add_executor_job(
|
||||||
data[API].get_devices)
|
data[API].get_devices)
|
||||||
|
except TokenExpiredError:
|
||||||
|
_LOGGER.warning("Cannot update devices due to expired token")
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
_LOGGER.warning("Cannot update devices")
|
_LOGGER.warning("Cannot update devices")
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user