I updated the code to work in Home Assistant 0.59.2. I implemented the code as a “package” (see code below). I did this before I realized I’d be foiled by not having a premium account to use the API controls though heh. So … it’s untested (I get the same error as switched). Thank you to GigabitGuy!
homeassistant:
#...
# Extra code is stored in these package. Look for more variable names here
packages:
pack_1: !include custom_components/spotify_playlist_player.yaml
#...
http:
# Secrets are defined in the file secrets.yaml
# api_password: !secret http_password
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# base_url: example.xxxxxxxxxx.org:8123
base_url: xxxxxxxxxx.duckdns.org
#base_url needed for Spotify component
api_password: xxxxxxxxxxxx
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
media_player:
#...
# Spotify media player only displays artwork of currently playing songs. It leaves the artwork up after Spotify is off. Also, no controls work (play/pause/stop/forward/back). Chromecast Audio works for displaying the same artwork and stopping play.
- platform: spotify
client_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
client_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
aliases:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: 'Web Player (Chrome)'
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: 'All Home Speakers'
Great work @Wheezy, I didn’t know about the new package feature, as I have been away from HA a while. I’m having huge issues with automations in general after trying to split it up/being away for a couple of months, maybe this approach can fix my issues as well.
I’m going nuts over this! I’ve must have tried a hundred different combinations of base_urls and redirect URI’s to no avail, I get either an Error 500 or a Invalid redirect URI no matter what I do.
The firewall ports are open, I can access HASS from outside my LAN, so my Duckdns redirect is working. I’ve tried using the local server IP as URI, I’ve tried my Duckdns address, with and without trailing slashes or port numbers. Still I get an error all the time. What am I doing wrong?
configuration.yaml:
http:
# Uncomment this to add a password (recommended!)
api_password: xXxXxXxXxXx
# Uncomment this if you are using SSL or running in Docker etc
base_url: XxXxXxXxXxX.duckdns.org
media_player:
- platform: cast
host: 192.168.1.152 #Kitchen
- platform: spotify
client_id: XxXxXxXxXxXXxXxXxXxXxXXxXxXxXxXxX
client_secret: xXxXxXxXxXxxXxXxXxXxXxxXxXxXxXxXx
(Yes, I have saved them)
From the log: 2017-12-16 22:57:47 INFO (Thread-5) [homeassistant.components.media_player.spotify] no token; requesting authorization
The last times I ran the authorization before writing this post, I got an INVALID_CLIENT: Invalid redirect URI in my browser, it doesn’t matter if I use my internal IP:port or my Duckdns address. Neither the HASS log or the journalctl output will give me any more details on whats wrong.
Edit: after changing my base_url to my local IP for the umptieth time it suddenly works.
http:
# Uncomment this to add a password (recommended!)
api_password: xXxXxXxXxXx
# Uncomment this if you are using SSL or running in Docker etc
base_url: http://192.168.x.xx:8123 #
Spotify whitelist as above.
Now that the authorization is done I just have to get it working too, that seems easier said than done…
With all respect @bonterra, but I don’t think this is the thread to be doing component troubleshooting in, and you might get better help in a dedicated thread.
Yeah, you’re probably right. Eventually I did get the authorization to succeed though, I added my details to my post above. I’ll give @Wheezy’s package a try once I find some time to sit down.
I figured out a way to accomplish casting Spotify Playlists to Chromecast Audio’s through Home Assistant. I use this project in tandem with a writeup on Mopidy and Icecast2, can be found here: https://www.vittoriomonaco.de/home-automation-part-7.html
dude this is exactly what i need, basically commenting to remember for later so i can adjust mine. I thought that w should ahve ability to set the text and value on input_selects so we don’t have to do anything weird.
Nice @robwolff3, I tried to play with Mopidy earlier on, but newer really got it going - that tutorial was just what I needed… Maybe its time to revisit and update this when I have the time.
Invalid service data for media_player.volume_set: expected float for dictionary value @ data['volume_level']. Got "'{{ states.input_slider.spotify_volume.state }}"