Skip to content

Commit

Permalink
Merge pull request #299 from emontnemery/adapt_ha_core_2022.3
Browse files Browse the repository at this point in the history
Adapt to upcoming changes in HA Core 2022.3
  • Loading branch information
fcusson authored Feb 27, 2022
2 parents 889c409 + bda8f52 commit 47bcb9a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions custom_components/spotcast/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ def get_spotify_devices(hass, spotify_user_id):
isinstance(entity, SpotifyMediaPlayer)
and entity.unique_id == spotify_user_id
):
_LOGGER.debug(
f"get_spotify_devices: {entity.entity_id}: {entity.name}: %s",
entity._devices,
)
if hasattr(entity, "_devices"):
_LOGGER.debug(
f"get_spotify_devices: {entity.entity_id}: {entity.name}: %s",
entity._devices,
)
else:
_LOGGER.debug(
f"get_spotify_devices: {entity.entity_id}: {entity.name}: %s",
entity.data.devices.data,
)
spotify_media_player = entity
break
if spotify_media_player:
# Need to come from media_player spotify's sp client due to token issues
resp = spotify_media_player._spotify.devices()
if hasattr(entity, "_spotify"):
resp = spotify_media_player._spotify.devices()
else:
resp = spotify_media_player.data.client.devices()
_LOGGER.debug("get_spotify_devices: %s", resp)
return resp

Expand Down

0 comments on commit 47bcb9a

Please sign in to comment.