Skip to content

Commit

Permalink
fix: avoid pruning devices in secondary accounts
Browse files Browse the repository at this point in the history
closes #1300
  • Loading branch information
alandtse committed May 18, 2021
1 parent 10c9fb5 commit a62a371
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,20 @@ async def async_update_data() -> Optional[AlexaEntityData]:
device_registry, config_entry.entry_id
):
for (_, identifier) in device_entry.identifiers:
if (
identifier
in hass.data[DATA_ALEXAMEDIA]["accounts"][email]["devices"][
if identifier in hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"devices"
]["media_player"].keys() or identifier in map(
lambda x: slugify(f"{x}_{email}"),
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["devices"][
"media_player"
].keys()
].keys(),
):
break
else:
device_registry.async_remove_device(device_entry.id)
_LOGGER.debug("Removing stale device %s", device_entry.name)
_LOGGER.debug(
"%s: Removing stale device %s", hide_email(email), device_entry.name
)

await login_obj.save_cookiefile()
if login_obj.access_token:
Expand Down

0 comments on commit a62a371

Please sign in to comment.