Skip to content

Commit

Permalink
fix(update_devices): prompt for login on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Sep 23, 2019
1 parent 81a7127 commit cb3a8fb
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions custom_components/alexa_media/__init__.py
Expand Up @@ -345,18 +345,21 @@ async def update_devices(login_obj):
['accounts'][email]['new_devices'])):
return
hass.data[DATA_ALEXAMEDIA]['accounts'][email]['new_devices'] = False
auth_info = await AlexaAPI.get_authentication(login_obj)
devices = await AlexaAPI.get_devices(login_obj)
bluetooth = await AlexaAPI.get_bluetooth(login_obj)
preferences = await AlexaAPI.get_device_preferences(login_obj)
dnd = await AlexaAPI.get_dnd_state(login_obj)
_LOGGER.debug("%s: Found %s devices, %s bluetooth",
hide_email(email),
len(devices) if devices is not None else '',
len(bluetooth) if bluetooth is not None else '')
if ((devices is None or bluetooth is None)
and not (hass.data[DATA_ALEXAMEDIA]
['accounts'][email]['configurator'])):
try:
auth_info = await AlexaAPI.get_authentication(login_obj)
devices = await AlexaAPI.get_devices(login_obj)
bluetooth = await AlexaAPI.get_bluetooth(login_obj)
preferences = await AlexaAPI.get_device_preferences(login_obj)
dnd = await AlexaAPI.get_dnd_state(login_obj)
_LOGGER.debug("%s: Found %s devices, %s bluetooth",
hide_email(email),
len(devices) if devices is not None else '',
len(bluetooth) if bluetooth is not None else '')
if ((devices is None or bluetooth is None)
and not (hass.data[DATA_ALEXAMEDIA]
['accounts'][email]['configurator'])):
raise RuntimeError()
except RuntimeError:
_LOGGER.debug("%s: Alexa API disconnected; attempting to relogin",
hide_email(email))
await login_obj.login()
Expand Down

0 comments on commit cb3a8fb

Please sign in to comment.