Spotify Playlist Player

Yes it is, sadly. It seems like this is what @phairplay and @maurizio53 is talking about. I’m afraid its down to a happy accident if somebody don’t experience it like @phairplay mentions. I would not spend time on getting it working with the spotify component, but try something with modipy instead, like mentioned somewhere above :slight_smile:

Ow balls!

I’ve been wrestling with this all day, only to browse through the comments for tips & tricks and this seems to be it :frowning:

Is there really no way to just tell hassio to play list X on Sonos Y?

I am wanting to setup playlists based on presence detection.

Am I right that I can tweak this project so Spotify will shuffle through multiple playlists? With the trick being to enable/disable playlists based on automated triggers from device.tracker? Thanks for any insight.

Was going to use scripting to modify amarok’s dynamic playlists, but it seems this project has done the heavy lifting for me already.

Hey @Nicras thanks for sharing this. The only issue I am having is with Select Source. For some reason the list of sources I am selecting are not responding but when I go to the media_player.spotify select source then it does reflect what has been selected.

Any suggestion?

Hi,
nice project, i recently learned about how Spotify Connect works and that you can use “Raspotify” to turn any raspberry pi into a spotify client. I can use them with the spotify app. But how do i get the other spotify controls into hass.io (not home assistant)? Where can i see the ID?

any fix on the source? I loose mine everytime and then have to play from it again on spotify to get it to work

The spotify playlist player found only alexa device not google device.

I’m getting script error when I put your code in my scripts folder as spotifyplaylist.yaml. Here is my script:

spotify_music:
  alias: "Play selected spotify playlist"
  sequence:
    - service: media_player.select_source
      data_template:
        entity_id: media_player.spotify
        source: >
          {% if is_state("input_select.spotify_source", "Kayhan's iMac") %} Kayhan's iMac
          {% elif is_state("input_select.spotify_source", "ECHODOTBUERO") %} ECHODOTBUERO
          {% elif is_state("input_select.spotify_source", "ECHODOTAUDI") %} ECHODOTAUDI
          {% endif %}
    - service: media_player.play_media
      data_template:
        entity_id: media_player.spotify
        media_content_type: playlist
        media_content_id: >
          {% if is_state("input_select.spotify_playlist", "Made In Germany") %} spotify:user:playlists.germany:playlist:5M7jfvXr6fiQ21U8jfe9aE
          {% elif is_state("input_select.spotify_playlist", "Murmel") %} spotify:user:1143893613:playlist:5dfbLgeesT8gixq1GTWBoU
          {% elif is_state("input_select.spotify_playlist", "Chillige Bässe") %} spotify:user:spotify:playlist:37i9dQZF1DX37cXruBmbRS
          {% elif is_state("input_select.spotify_playlist", "Chillstep") %} spotify:user:kent1337:playlist:6IjDl5eRczFdgZkKYXhuHZ
          {% elif is_state("input_select.spotify_playlist", "Mixed Hip Hop") %} spotify:user:1143893613:playlist:4yuXhTpPFSTnRSYmAN8mse
          {% elif is_state("input_select.spotify_playlist", "Mixed Electro") %} spotify:user:1143893613:playlist:1grR3x1MSPlyfS6VsaSzPn
          {% elif is_state("input_select.spotify_playlist", "Mixed Rock") %} spotify:user:1143893613:playlist:2ECMyR5ovezJBGQDnL3w23
          {% elif is_state("input_select.spotify_playlist", "Mixed Dub") %} spotify:user:1143893613:playlist:093q3iMD3lAA4h5oatDJPh
          {% elif is_state("input_select.spotify_playlist", "Good Feeling") %} spotify:user:1143893613:playlist:0rHdZMqeSR4XVvPf6QmFM4
          {% elif is_state("input_select.spotify_playlist", "Nightair") %} spotify:user:1143893613:playlist:2C4xXSYKJp0CYwIyWhODpD
          {% elif is_state("input_select.spotify_playlist", "Streetbangers") %} spotify:user:1143893613:playlist:1JzR2qe9P3EOjgSyVNJ80R
          {% endif %}

And error message:

Invalid config for [script]: [spotify_music] is an invalid option for [script]. Check: script->script->spotifyplaylist->spotify_music. (See /config/configuration.yaml, line 170). Please check the docs at https://home-assistant.io/components/script/

any advice?

solved after removing " spotify_music:" in script file. :slight_smile:

How can I get podcasts working?

1 Like

I have the same issue.
Exactly the same error.
Did you find a solution?

And i get an error on the source select. I think only when there is no source to select:
WARNING (MainThread) [homeassistant.components.input_select] Invalid option: (possible options: HTPC, Rick)

Same thing here.
The source explanation is not well documented.
Some pages don’t talk about select_source, could be a different/older version, which makes it a bit harder for newbees who also want to configure this.

  • In the spotify developers console, I don’t see any sources
  • I don’t know how to find the alias numbers I sometimes see in code
radiocontrol:
    alias: Play Radio on Google Home
    sequence:
      - service: media_player.volume_set
        data:
          entity_id: media_player.speaker_master_bedroom
          volume_level: 0.2
      -  service: media_player.play_media
         data_template:
           entity_id: media_player.speaker_master_bedroom 
           media_content_id:  "spotify:user:spotify:playlist:37i9dQZF1DWSkkUxEhrBdF"
           media_content_type: "playlist"

Sometimes I see the following code for source select, for which I guessed the source name:

      - service: media_player.select_source
        data_template:
          entity_id: media_player.spotify
          source: "Master Bedroom"

As written above, I only hear a ding when the script executes.
With other mp3 audio streams, it works perfect.

I would like to know how to continue, do I need to define the sources? Then my code gives an error when I use select_source.
Do I need to define aliasses? If yes, Where can I find those numbers to refer the alias to?

Got mine working, maybe it helps;

input_select:
  spotify_source:
    name: 'Source:'
    options:
      - HTPC
      - Rick
    initial: HTPC
    icon: mdi:speaker-wireless

################################################################################
## SENSORS
################################################################################

sensor:

  - platform: template
    sensors:
      spotify_source:
        friendly_name: "Spotify Source"
        value_template: "{{ state_attr('media_player.spotify', 'source') }}"


automation:

  ################################################################################
  ## SOURCE SYNC
  ################################################################################

  - alias: 'Spotify Source (Sync)'
    id: 'spotify_source_sync'
    trigger:
      - platform: homeassistant
        event: start
      - platform: state
        entity_id: sensor.spotify_source
    condition:
      condition: template
      value_template: >
        {{ states('sensor.spotify_source') in
             state_attr('input_select.spotify_source', 'options') }}
    action:
      service: input_select.select_option
      entity_id: input_select.spotify_source
      data_template:
        option: "{{  states('sensor.spotify_source')  }}"
2 Likes

Hi Chimichanga,

Are you saying that you got your spotify to be able to play on your chromecast and that it comes up as a source?

I looked through your code abovee I can’t see what part of this links to your chromecast or finds the chromecasts?

Cheers

Hi Vija,

No, i don’t have a Chromecast as Source. That’s why you can’t find it.
But i defined the Sources which are available in the Spotify app. In my case that’s ‘HTPC’ and ‘Rick’ (my phone). If Chromecast is one of your sources, you should get this working on that source.

I had the same problem that my spotify source was gone in ha. The source get erased after a few days/hours. But since i changed the configuration of my raspotify instance (on an other rpi then my hassio) i never have the issue. i think the problem had to do something with the spotify client needs to be visible in Spotify connect .
I hope this helps someone.

# To make your device visible on Spotify Connect across the Internet add your
# username and password which can be set via "Set device password", on your
# account settings, use `--username` and `--password`.

hi
i have the issue with spotify forgetting the source when idle, are you suggesting your config you posted keeps them active or am i missing something.

Was inactive for a while, but the config doesn’t keep the source active. It only checks if the defined source is available. I must admit, I only use is at home, when that source is already up and running. Can’t confirm if it works when it’s unavailable.

Is the shuffle function working for anyone? Doesn’t seem to do anything for me:

- service: media_player.shuffle_set
  data:
   entity_id: media_player.spotify
   shuffle: ‘true’

Edit: I’m stupid and had an extra space before the data parameters. It works.

1 Like

Did you find a solution to this ?