Spotify ignoring source

Hi folks,

I’m not sure if there is a bug in my code or the Spotify component, but so far it seems like it just ignores the source selection.

Observed behavior so far:

  • Nothing happens if i specify a Chromecast (have seen others with same problem)

  • If i specify my iPhone or iPad it simply just plays on the device last used by spotify, NOT the specified source, unless this this just happens to be the last used device.

  • This also goes for Chromecast’s, if I last used a chrome cast, then it plays there.

    morgentilstand:
    sequence:

    • service: scene.turn_on
      entity_id: scene.morgentilstand
    • service: media_player.select_source
      data:
      entity_id: media_player.spotify
      source: iPhone
    • service: media_player.play_media
      data:
      entity_id: media_player.spotify
      media_content_type: playlist
      media_content_id: spotify:user:spotify:playlist:37i9dQZF1DXdd3gw5QVjt9

Is it me doing something wrong here?

Maybe this error code is relevant, its been spitting out like crasy in my log.

2017-05-27 06:11:58 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.spotify fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    None, self.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/spotify.py", line 157, in update
    devices = self._player.devices().get('devices')
AttributeError: 'NoneType' object has no attribute 'get'

The problem seems to be related to the dynamic nature of Spotify Connect, as far as I can tell the above error message is due to Spotify Connect “forgetting” all my devices.

Fixed this by opening spotify on my phone and iPad and then running the script again.

I don’t know if this can be fixed or if this is entirely an issue on Spotifys side.

What are others experiences?

1 Like

I have the same issue. Component forgets my devices. I don’t know how to fix this.

I’m not a coder, sadly, so I don’t know if this is duable. But it would be nice to have the posibility of “forceing” the Spotify Component to remember devices, maybe with a config like this

spotify:
  source: 
  'spotify-connect-name1'
  'spotify-connect-name2'

Maybe this could fix the chromecast issu as an extra bonus too :slight_smile:

In the next HA releasy will be
https://github.com/home-assistant/home-assistant/pull/7702

That seems promising, let’s hope it’s soon. I’m not sure where the alias value comes from?

With this new version of the component detected devices will be shown in HA log.

Thanks, lets hope it fixes it, I have disabled spotify for now, it has completly spammed my log with error messages again.

I have similar issues. Would love a solution so ill keep my fingers crossed for that update!

I just made a small test, it seems to be working now, spotify is able to switch from iPhone/iPad to a chromecast when I run the script.

However, I don’t see any aliases in the log or anywhere?

@GigabitGuy You have to set logger level to info to see aliases. Unfortunately, this new version of the component generates an error every minute when all the players are disabled. I still can’t use it normally.

Thanks @Bieniu, think I got them now.

Are bummer, maybe you can get around that by setting the logging level for the spotify component higher than the warning? If its log spamming causing problems?

I once tried it and could not find the right domain to block logs. Spotify and homeassistant.component.media_player.spotify did not work.

@Bieniu did you actually get the aliases to work? Mine does not seem to do anything, Spotify just re-discoveres my devices on startup like there isn’t anything in my config, but there is:

    media_player:
          - platform: spotify
            client_id: ******
            client_secret: *******
            aliases:
                3fc03b************************: 'Stue'
                7de197************************: 'Køkken'
                E3ADD********************************: 'Lejlighed'
                f8c8810************************: 'iPad'
                c8c604************************: 'iPhone'
                07d99a********************************: 'Macbook Pro'

Regarding the log blocking, try and set the homeassistant.components.media_player: (without spotify) to critical or fatal

Yes, aliases work for me. My config:

- platform: spotify
  client_id: !secret spotify_client_id
  client_secret: !secret spotify_client_secret
  cache_path: /home/homeassistant/.homeassistant/.spotify-token-cache
  aliases:
    5d660xxxx: 'Gabinet'
    d21e5xxxx: 'Salon'

and

Aren’t you missing Salon in your source list?

This is driving me nuts, it worked flawlessly the first time around, but now I can’t seem to get me two chromecast + their group, to stay in the source_list. The speaker group keeps resetting all the sources.

Yes, my players also disapear after some time. Aliases only change names of the players.

I think we need a way to hardcode the sources into the spotify component, this should be douable.

This still seems to be a problem.
I cannot play a playlist after some idle time because Spotify doesn’t know the source anymore.
Is there another fix for this?

1 Like