I want to play a spotifyplaylist to my chromecast. I did a clean install couple of days ago to the latest version. Had no troubles setting up spotify nor the chromecast however combining them isnt working.
I attempted to run this script:
My chromecast seems to react only showing a blue chromecast icon on a black background and nothing else, no sound.
In my log i found this:
17-05-06 11:09:01 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.spotify fails
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-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 "/usr/local/lib/python3.4/dist-packages/homeassistant/components/media_player/spotify.py", line 158, in update
devices = self._player.devices().get('devices')
AttributeError: 'NoneType' object has no attribute 'get'
Is my script wrong? Am i missing dependencies? Did i set something up wrong?
1st I use data_template instead of data and it works on my allplay speakers and Amazon echo.
2nd media_player.Wouter big letters are a problem
Try media_player.wouter instead.
3rd is media_player.wouter your chromecast or your player created from spotify
if it’s your chromecast try media_player.spotify instead.
Tried all suggestions, none worked unfortunately. media_player.Wouter works in an instance where i start radio so i guess it doesnt matter (although i tried lowercase aswell since u suggested it).
Also tried data_template without any change in the results. Also tried your third suggestion and it also got me curious. Mostly because i dont understand at what point it should know to play it on the chromecast?
The odd thing is that when i am already playing something from spotify on TV/phone/chromecast it works to change the playlist to the one in the script however it doenst initiate to play it on the chromecast when it isnt on yet…
The media_player.spotify is an independent media player from your chromecast, as it represents spotify connect (like on your phone). So use media_player.spotify instead of wouter. You can chose the player either directly in the spotify media player in the frontend or by calling it in a script or
an automation like this to switch to the right source. (I just use the state of my Harmony remote normally.
Try this script works for me Just change the source, to what the name of your chromecast is in Spotify connect. I hope that helps! Cheers Mat
# Play random playlist and switch to Amazon Echo
script:
spotifydemo:
alias: 'Spotify on echo'
sequence:
- service: media_player.select_source
data:
entity_id: media_player.spotify
source: Mathias' Echo Dot
- service: media_player.play_media
data:
entity_id: media_player.spotify
media_content_type: playlist
data_template:
media_content_id: >
{%- set plists = ["spotify:user:spotify:playlist:37i9dQZF1DX55dNU0PWnO5",
"spotify:user:spotify:playlist:37i9dQZF1DWVyfHu8SNQgH",
"spotify:user:spotify:playlist:37i9dQZF1DX9OTdoPfdJpF",
"spotify:user:spotify:playlist:37i9dQZF1DX0N8QTiMHLoT",
"spotify:user:spotify:playlist:37i9dQZF1DWZtZ8vUCzche",
] -%}
{% set pindex = (range(0, (plists | length - 1 ) )|random) -%}
{{ plists[pindex] }}
Thanks again, i think im one step closer: I adjusted my script to resemble yours. The problem is probably not my script. When i check in the frontend the spotify component i cant selecht my chromecast as a source!
When i start it from my phone and tell spotify to play it on the chromecast in the frontend the source correctly shows it is playing on my chromecast and i can pause playing using both the chromecast component aswell as the spotify component.
Could the problem be that i cant correctly select the source because of some reason?
Seems to be really a chromecast thing then.
your script nicely works for me just listening to System of a Down now
I read in another posting that someone had trouble with his amplifier not showing up as well.
Sorry I can’t be of further help then.
Nope; couldnt find a way to fix this. As others stated i can play to my phone/PC but not my chromecasts…
Real big bummer to me and i hope someone knows how to fix this or have a workaround.
The problem is, at least from what i have been able to figure out, that the spotify player (connect implementation) in Home Assistant can’t “see” chromecast’s or Google Home’s unless you are already playing spotify from another source (say a android phone) on one of them.
This behavior is from what i can tell identical to the Spotify app on Windows.
So you can try to to run your script while you are playing music from spotify on your chrome cast and it should work. But if you ain’t the script will do nothing at all.
All in all; I think this is a problem from Spotify’s part and not Home Assistant
In short, if I understand this compnent correctly, it isn’t connected directly to Spotify, but rather tells a spotifyclient on a computer or phone what to do.
That spotify client provides a list of available devices to cast to and that list is the problem. Spotify only give home assistant access to the devices that are currently available, if thchromecast is turned of or connected to something else, it’s no longer available for home assistant.
I don’t think that the component is interacting with spotify connect correctly. It simply deletes available sources at random when switching it seems.
I would recommend to try and play around with something like mobidy as an alternative. It seems a bit more complicated, but as far as I have understood it acts more like a dedicated player - nullefying the whole spotify connect debuggel. I will give it a try in the near future myself
It is working with my Phone and desktop when i leave the Spotify app/program on for a period of time.
Unfortunatly this isnt the case for my chromecasts. Hope there will be a way to solve this!
My thoughts are if we can install Spotify on a Pi we won’t be dependent on a computer or phone.
My knowledge of Raspbian and or linux are limited so I’m asking if you think this is feasible?