Spotcast - custom component to start playback on an idle chromecast device

Lets continue this in the other thread where you posted first

I just started using HA and would like to use this for more consistency with my Google Nest Mini, but Iā€™m not really sure how to proceed with this component.
I use a custom mini-media-player card to control spotify and source (where its being played) from, so I donā€™t know how to include the spotcast start. Would I have to create a script that is just constantly running to make sure the nest mini is always discoverable?

Any idea on how to start the latest episode of a podcast on Spotify?
Every podcast has its URI, and each of its episodes has their respective URIā€™s.
This is similar to an album or playlist, which has their own URI, and each of the songs within has their unique URI.

However, the podcast URI behaves differently from the album and playlist variants.
If spotcast.start is called with the podcast URI, the first episode of the podcast is started.
The second episode can be played by clicking on next song.
The shuffle and random_song keys do not seem to do anything.

Is there any way to reverse this play order such that the latest episode is always played?

Can you make it work using there console?
https://developer.spotify.com/console/player/ using the /play method? If so I can implement it in spotcast

I donā€™t think there is a simple way to play the latest episode of a show by just using the show URI and the player/play method. Right now Iā€™ve solved it for my self by getting the URI of the latest episode using the shows/{id}/episodes method. Thanks for referring to the console.

Update:
I thought that getting the latest episode URI via an http request with the shows/{id}/episodes command would solve this for me. Unfortunately, at the moment of writing, Spotify appears not to support podcast episode playback with a spotify:episode:{id} uri and the player/play command, and returns a error ā€œNon supported context uriā€. This issue was tracked here https://github.com/spotify/web-api/issues/909 before Spotify migrated to their own community forum.
So anyone reading this, there is no point in starting podcast playback via Spotcast.

@fondberg Suddenly, after a reset, i am getting tons of these errors:

https://pastebin.pl/view/ec148463

and as result, all the featured playlists of the nations i choosed are not anymore displayed


I posted in pastebin for the big log.

EDIT: If i go to: https://api.spotify.com/v1/browse/featured-playlists%3Flocale=en&country=FR&limit=20&offset=0

I get:

{
  "error": {
    "status": 401,
    "message": "No token provided"
  }
}

This is spotify having problems, nothing i can do

That is too bad

Hi @fondberg So I noticed an issue that never seems to have been solved (since Iā€™m running this, 9 months ago). Though Iā€™m not sure ifā€™s a spotcast error, a Chromecast integration error or a combination.

After a sertain ammount of time (or maybe service calls) spotcast refuses to cast to a certain chromecast end device. In this case itā€™s a group speaker (group of 2 made through Google Home, letā€™s call this Multispeakers) Casting to the individual speakers does work though. This is what comes up in my logs at that moment:

Logger: pychromecast.socket_client
Source: /usr/local/lib/python3.8/site-packages/pychromecast/socket_client.py:409
First occurred: 11:00:06 (11 occurrences)
Last logged: 11:15:18

[(10.0.1.20):42259] Failed to connect, retrying in 5.0s

I remember a few versions ago this would cause the entire HA system to lock up. You then changed the timeout to 5s, so it wouldnā€™t keep trying (which caused the freeze).

Now before you say: this is an error with the Chromecast integration: casting other stuff (like a radio stream) works fine to that same group speaker. Only the spotcast service call seems to get this error. Also there is nothing wrong with Spotify stream, I can cast to that speaker fine using the iPhone/desktop apps.

When I disconnect an individual speaker, suddenly that specifiek cast group becomes unavailable in Home Assistent. Also when that individual speaker gets connected again. Casting to a different group (letā€™s call this Party Speakers, which contains those 2 speakers and one more extra) works fine. I notice the The only way to resolve this, is restart Home Assistant (which defeats the purpose of automations).

Is this something you have experienced or have seen reports off (maybe with the Chromecast integration?). Before I post my issue on the HA github, I wanted to ask you about this because of this part: casting other stuff (like a radio stream) works fine to that same group speaker. Only the spotcast service call seems to get this error. Also there is nothing wrong with Spotify stream, I can cast to that group fine using the iPhone/desktop apps.

I think the latest release might solve this

2 Likes

I saw that right after I posted this, was a nice surprise haha. Iā€™m gonna test this and hope for the best, thanks again!

1 Like

It is work like charm. Thanks for the good work!

Home Assistant 0.114.2

With last release of spotcast and spotify card

1 Like

Did it work?

Unfortunately I had to restart HA because I was editing my setup/UI a few times. Having said that, itā€™s now going strong for almost 3 full days. So it looks like it might be fixed. Iā€™m gonna wait with restarting HA to and see it this continues for 2 more days, then Iā€™ll know for sure. I will report back then.

@fondberg So I now have HA running for little over 4 days without rebooting. Right now I am having issues again with group speakers (strarted just now). I donā€™t know if this has to do with spotcast or the Google Cast integration itself. I tried casting a random radio url on that speaker through HA (using service call). That works fine, plays instantly on group speakers. So I think the same issue as I reported back then. This is the log:

Logger: pychromecast.socket_client
Source: /usr/local/lib/python3.8/site-packages/pychromecast/socket_client.py:408
First occurred: 27 augustus 2020 20:57:59 (25 occurrences)
Last logged: 14:10:18

* [Sony(10.0.1.19):8009] Failed to connect to service HT-NT5-7c07cffcd55821223ea382b1dbb3cce1._googlecast._tcp.local., retrying in 5.0s
* [Party Speakers(10.0.1.4):49494] Failed to connect to service Google-Cast-Group-D35A28A95DCB4496AEB0843D4D58A0A2._googlecast._tcp.local., retrying in 5.0s
* [Super Groep(10.0.1.21):32182] Failed to connect to service Google-Cast-Group-0F6F84E76C09439F8F266137D1DF381D-1._googlecast._tcp.local., retrying in 5.0s
* [Multispeakers(10.0.1.20):42259] Failed to connect to service Google-Cast-Group-F1EB72FC72AE4BE6B7B9BD6230E1FCBA-1._googlecast._tcp.local., retrying in 5.0s
* [Multispeakers(10.0.1.20):42105] Failed to connect to service Google-Cast-Group-9c9e5672f3a74f74b88cb9ff399e459c._googlecast._tcp.local., retrying in 5.0s

The strange part is: all speakers work with Spotcast (also the group ones) except Multispeakers. And other casting methods work fine on Multispeakers as well.

And you are sure you are running the latest spotcast?

Yes I am. I updated Spotcast as soon as it was on HACS a while ago. I check all updates daily for all HACS addons etc (just checked again). One thing I noticed as well:

I restarted HA and as soon as the server went offline, my speaker tried to play something from Spotify (but it failed and loaded nothing). Kinda as if the service call was on hold and as soon as HA went offline it went through. Hard to reproduce this though. Gonna try and keep HA running without restarts to see if it happens again.

Hmmm. Your log seems to suggest that pychromecast cant connect yo any of the devices. Pychromecast yses zeroconf which relies on mDNS (the .local host names) so I would say your HA instance has some issues at the time of the log.

Can you send a log of what spotcast logs in debug mode during the failure?

Hello. Iā€™m getting the following error. Any ideas?

2020-09-01 22:47:09 ERROR (MainThread) [homeassistant.components.homeassistant] Component error: spotcast - No module named ā€˜pychromecastā€™

I tried installing pychromecast via pip but that didnā€™t seem to help any.

How have you installed HA?