Spotify Script does not work

Hi All,

I have been trying to make Spotify work on two devices, My PC and My Phone.

Sources:
HOME
SM-G955F

So far I have managed to connect to my Developer account to my homeassistant app with no issues at all. Integration went well and I have managed to setup media player for Spotify inside my homeassistant platform.
media_player.spotify

In my configuration.yaml I have added:

input_number:
  spotify_volume:
    name: Volume
    icon: mdi:volume-high
    min: 0
    max: 1
    step: 0.05

input_select:
  spotify_playlist:
    name: 'Playlist:'
    options:
      - PlayList01
      - PlayList02
      - PlayList03
      - PlayList04
      - PlayList05
      - PlayList06
    icon: mdi:spotify
  spotify_source:
    name: 'Source:'
    options:
      - HOME
      - SM-G955F
    icon: mdi:speaker-wireless

The above was changed since I want to make it simple and not expose to much in my code.
So, As you can see I have added all Six of my PlayLists and Two of my Sources.
I went on and added a script inside my scripts.yaml file as follow:

spotify_music:
# alias: Play selected spotify playlist
  sequence:
  - service: media_player.volume_set
    data:
      entity_id: media_player.spotify
      volume_level: '0.40'
  - service: media_player.select_source
    data_template: 
      entity_id: media_player.spotify
      source: >
        {% if is_state("input_select.spotify_source", "HOME") %} HOME
        {% elif is_state("input_select.spotify_source", "SM-G955F") %} SM-G955F
        {% 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", "PlayList01") %} spotify:user:spotify:playlist:57ohW1foqFuMtgjU1TzfaX
        {% elif is_state("input_select.spotify_playlist", "PlayList02") %} spotify:user:spotify:playlist:64pgVtWiTkZBUhiS6LZPLO
        {% elif is_state("input_select.spotify_playlist", "PlayList03") %} spotify:user:12131571557:playlist:4aNHl761iH7P1i7uxaqX5W
        {% elif is_state("input_select.spotify_playlist", "PlayList04") %} spotify:user:spotify:playlist:70D7H171aLoj6yUc7bGaq4 
        {% elif is_state("input_select.spotify_playlist", "PlayList05") %} spotify:user:spotify:playlist:1gEnUo4KSFuGbYAI4eLK1S
        {% elif is_state("input_select.spotify_playlist", "PlayList06") %} spotify:user:spotify:playlist:1GEV89tcYrH9PupyiXZMIA
        {% endif %}

Again Id’s were changed as well.
I have done configuration check and it went successfully.
But, When I tried to run the script I got the following Error:
Failed to call service script/spotify_music. unsupported operand type(s) for &: 'NoneType' and 'int'
script is not running at all.
In automation.yaml I have added the following code:

  - id: set_spotify_volume
    alias: 'Set Spotify Volume'
    trigger:
    - platform: state
      entity_id: input_slider.spotify_volume
    action:
      - service: media_player.volume_set
        data_template:
          entity_id: media_player.spotify
          volume_level: '{{ states.input_slider.spotify_volume.state }}'

I have also added some small code in more files just to share with you the complete setup i tried to achieve. (I don’t think that they effect anything… but who knows)
in customize.yaml I have added:

script.spotify_music:
  friendly_name: 'Play'
  icon: mdi:play

and in groups.yaml I have added

music_spotify:
  name: Music 
  entities:
  - input_select.spotify_playlist
  - input_select.spotify_source
  - script.spotify_music
  - input_number.spotify_volume

I would be happy to know why my script does not work and hopefully to be able to make my spotify run from my main hass.io platform as I want everything to work from.

I would be happy if you could assist me.
And to give credits when due :
I have followed all my setup according to this link - with some adjustments
Spotify Playlist Player - Community Home Assistant

Thank you all for everything - I have learned so much and I am so happy to be a part of the community.
Thank you!

I was struggling with mine as well. It seems to run a lot more smoothly with the new Spotify integration in 0.105. Suggest trying it again if you haven’t made progress.