Spotify ignoring source

Welcome then!
Without really knowing, could it be that you used aliases in configuration.yaml without actually putting any in there?

Component not broke. Works ok for me, but not perfect. For instance, if the media player is off and an automation trigger, Spotify will play on something else. The players of my ex is still in my list, she could be more thrilled. Besides that, I’m happy.

Only you can decide if it is worth your time, but there’s really not much to it. Make sure logger is configured similar to post 22, Spotify needs to log “info”. I guess you need to remove aliases in your configuration.

Start HA.

I use SSH and write “journalctl -fu [email protected] | grep New” and get stuff like “Jan 13 13:12:43 hassbian hass[450]: 2019-01-13 13:12:43 INFO (Thread-18) [homeassistant.components.media_player.spotify] New Devices: {‘Pappa Speaker’: ‘8e2a9dxx3ca46275xxx2fadb0’, ‘Pappa’: ‘25f9ccccc61502da477ccccc5ead5bac1931’}”.

Use these for aliases in your configuration as stated in the documentation.

Good luck!

Ah, and one more thing… I agree with a lot of the people above, the component isn’t perfect. But to me it is, I guess it could be since I only use it with automations.

The Spotify thingy in the frontend constantly “forgets” the media players. I use a couple of chromecasts with external speakers and the wonderful Audio Pro C5:s who uses LinkPlay. “If door to patio is open, randomly play playlist(s). When movement in kitchen, do the same. When door closes, movement stops or TV is on stop”.

To me, that always works, except if I physically have removed the players and Spotify play somewhere else on something else…

/Johan

Thank you!

Havent added any aliases at all, since I cant find them… :stuck_out_tongue:

journalcrt yields only “-bash: journalctl: command not found”. As I said, completely new to this, been tinkering with it for two days, so might be my setup is incomplete or something?

What you are using it for, is what I would like to use it for as well. Not critical to be able to control it from the frontend.

OK.
Well, did this is a long time ago but let me give it a try…

I believe in your configuration.yaml you have something like;

media_player:
  - platform: spotify
    client_id: !secret spoclient_id
    client_secret: !secret spoclient_secret
    aliases:
        2817660cxxxxxxxxxxxxxxxxxxxxxxx8648e207: 'Kitchen'
        f610e96fxxxxxxxxxxxxxxxxxxxxxxxxx034be7ff0: 'Gymmet'
        93fed0041a0xxxxxxxxxxx9c1b39cc60b: 'Pappas Sovrum'

if that’s true, you should remove the word aliases since that’s what I think is wrong. Then restart the machine and it should work…?

I use Hassbian, I guess you’re on something else, hass.io perhaps? Depending on what you run the logs might be in different locations.

Good Luck!

Sorry to dig this thread up. But has anyone been able to get away around this?

I would love to have this working on my HA

so I was digging around HA to understand why my HA wont retain the devices used by spotify and I stumbled on the following link

it seems spotify it’self isn’t retaining the list of devices not HA

when i play anything it appears in on the website, after a while it disappears

This is also the argument I meet back when I raised the issue (making it a non-issue) - however I don’t see this behavior on my iPhone or MacBook spotify apps. Once in a while maybe, but not as much - maybe they do something to discover the devices more aggressively or something like that.

I just think it odd that it works for some and not for others, I even tried signing up to a new account to see if that resolved my issue,

I’d love to have this hooked up to my HA

I am far from proficient with all of this, but I had an idea that I thought may be worth sharing. When I try to cast to google devices via Spotify on my desktop, I cannot see any of the google devices. I can only see the desktop I am on and a Firestick. The issue is referenced here (https://community.spotify.com/t5/Desktop-Windows/Spotify-Connect-amp-Google-Home/td-p/4642461) and I can confirm that I see all of my devices on my phone, but not from my desktop.

Maybe the limitation is with the Spotify API or the way that Home Assistant is using it, because it functions very similarly to the way that using Spotify on my desktop does. If I start playing music on a google home (via voice command or casting from my phone), I can see the google home on my desktop Spotify client in the devices menu but the moment I switch it to my desktop via the devices menu on my desktop the google home disappears. This is the exact same way that sources show up on my HA front-end and it behaves the same if I switch devices from the HA front-end.

Again, I have no idea how to begin remedying this, but I figured I would throw it out there in case someone who has the knowledge wants to take it and run with it at some point. Maybe there is a way to utilize the iOS or Android API to see google devices with more reliability.

Cheers

The problem is indeed with Spotify API. There’s a few issues on Spotify open. I have been researching a bit. Google Assistant can actually start the cast too. Hence, I was thinking of a workaround to make a request to Google Assistant to start the cast, then take over the control in Home-Assistant. In that sense, I wonder whether the Google Assistant SDK Add-on could make it work. Does anyone has it installed to check whether it’s possible to make REST/HTTP calls or use it in scripts?

1 Like

I think I could indeed dig up ids using Spotify Rest API as per the link shared by phairplay.
But how do you use spotify in automation? I tried to use spotify.play_playlist service as described on https://www.home-assistant.io/integrations/spotify/, but it reports no activ device found (I can play on one and Rest API reported it back!)

Sure. This is really ugly, but I haven’t looked at it for a couple of years and it works. I had some strange issues with lists starting with the same song and volume so there’s quite a lot of room for improvement. Again, it does what I want it to do…

- alias: Köksmusik på på
  trigger:
    platform: state
    entity_id: binary_sensor.koksogat_sensor
    to: 'on'
    for:
      minutes: 2
  condition:
  - condition: time
    before: '22:00:00'
    after: '18:00:00'
  - condition: template
    value_template: "{{ not is_state('media_player.spotify', 'playing') }}"
  - condition: template
    value_template: "{{ not is_state('media_player.appletvardagsrum', 'playing') }}"
  - condition: template
    value_template: "{{ not is_state('media_player.appletvardagsrum', 'paused') }}"
  action:
  - service: media_player.select_source
    data:
      entity_id: media_player.spotify
      source: "Kitchen"
  - service: media_player.volume_set
    data:
      entity_id: media_player.spotify
      volume_level: 0.0
  - service: media_player.shuffle_set
    data:
      entity_id: media_player.spotify
      shuffle: true
  - service: media_player.play_media
    data:
      entity_id: media_player.spotify
      media_content_type: playlist
      media_content_id: spotify:user:XXXXX:playlist:XXXXXX
  - service: media_player.shuffle_set
    data:
      entity_id: media_player.spotify
      shuffle: true
  - service: media_player.media_next_track
    data:
      entity_id: media_player.spotify
  - service: media_player.volume_set
    data:
      entity_id: media_player.spotify
      volume_level: 0.45

- alias: Köksmusik på lugnt
  trigger:
    platform: state
    entity_id: binary_sensor.koksogat_sensor
    to: 'on'
    for:
      minutes: 2
  condition:
  - condition: time
    before: '18:00:00'
    after: '05:30:00'
  - condition: template
    value_template: "{{ not is_state('media_player.spotify', 'playing') }}"
  - condition: template
    value_template: "{{ not is_state('media_player.appletvardagsrum', 'playing') }}"
  - condition: template
    value_template: "{{ not is_state('media_player.appletvardagsrum', 'paused') }}"
  action:
  - service: media_player.select_source
    data:
      entity_id: media_player.spotify
      source: "Kitchen"
  - service: media_player.volume_set
    data:
      entity_id: media_player.spotify
      volume_level: 0.0
  - service: media_player.shuffle_set
    data:
      entity_id: media_player.spotify
      shuffle: true
  - service: media_player.play_media
    data:
      entity_id: media_player.spotify
      media_content_type: playlist
      media_content_id: spotify:user:spotify:playlist:XXXXX
  - service: media_player.shuffle_set
    data:
      entity_id: media_player.spotify
      shuffle: true
  - service: media_player.media_next_track
    data:
      entity_id: media_player.spotify
  - service: media_player.volume_set
    data:
      entity_id: media_player.spotify
      volume_level: 0.22

- alias: Köksmusik av
  trigger:
  - platform: state
    entity_id: binary_sensor.koksogat_sensor
    to: 'off'
    for:
      minutes: 5
  - platform: state
    entity_id: media_player.appletvardagsrum
    to: 'playing'
  - platform: state
    entity_id: media_player.appletvardagsrum
    to: 'paused'
  action:
  - service: media_player.volume_down
    data:
      entity_id: media_player.spotify
  - delay: '00:00:1'
  - service: media_player.volume_down
    data:
      entity_id: media_player.spotify
  - delay: '00:00:1'
  - service: media_player.volume_down
    data:
      entity_id: media_player.spotify
  - delay: '00:00:1'
  - service: media_player.volume_down
    data:
      entity_id: media_player.spotify
  - delay: '00:00:1'
  - service: media_player.media_pause
    data:
      entity_id: media_player.spotify
  - delay: '00:00:1'
  - service: media_player.volume_set
    data:
      entity_id: media_player.spotify
      volume_level: 0.22
1 Like

@frenck, can you please take a look at this?

There is not much to look at. The current integration in 0.105 shows all sources provided by the Spotify API. There is no filtering on our end for that.

Thanks for the reply!!

Yeah, we’ve settled that this is a Spotify API problem…
But @peglegreg is right… mobile apps have a different way of fetching the available sources on the local network, since they all show as available most of the time. Isn’t there any way for the HA integration to make a scan the same way the mobile apps do instead of fetching the sources from the API?

What you see additionally on your mobile, are the Chromecast devices.

In theory, it should be possible. But that is not made/created easily.

Yes, but not only…
For instance, my Samsung TV, my PS4… they show up in my android app but not on the desktop app, which also gets the source list from the API.
There’s only one source available at all times and that’s my Yamaha receiver. I wonder why…? :thinking:

Why are the Chromecast devices listed in the Spotify Lovelace Card, while they are not available in the official Spotify API, and thus not in the sources of the media_player in HA? Anyone knows?

1 Like

I had the same problem but thanks to reading about Spotify Lovelace Card, I found the following solution. Works perfect for me!

1 Like

My wife’s Spotify account also doesn’t list any device. I can stream to Chromecast devices now through Spotcast, but I have other devices I want to start playback on (HEOS in my case). None of these are in the source_list of the media_player entity of the Spotify integration of my wife, until I start the playback myself manually through the Spotify app on her phone. Then the source_list is populated as it should be.
Also checked the api of Spotify and got this returned:

{
  "devices": []
}

The web player of Spotify also returns no other speakers at all :frowning:

Guess there is no way to resolve this issue for now?