Is there a reason why you are trying to do this and not use the Plex App? Is it just a coding experiment or is there some reason why you want to bypass the Plex app?

There is a reason. Now that this is working, I have tied it to my Google home without waiting a year for Plex to get their support sorted. I can now say, "Okay Google, watch Westworld season 1 episode 1" and it will start playing the appropriate episode on my Chromecast from Plex.

Ah, I had NOT indeed worked out the transient token bit. I felt like maybe I needed to fetch one, but hadn't quite worked out how. Are you sending a SETSTREAM and a LOAD or just a LOAD to actually get things playing? If a SETSTREAM, is that going to the plex namespace or the media namespace?

I just used a LOAD.
For SETSTREAM I'm using the following in my controller (using the Plex namespace).

I'm headed out to dinner and won't be back for a while, BUT, it requires editing the plex.py file in the controller folder of pychromecast. I JUST got it to start playing and the like myself thanks to mcneishh's hints. I'm attaching a basic functional PlexApiController:

Hi, thanks a lot for your code! I managed to connect to the Chromecast using pychromecast and to plexapi, but unfortunately every time I try to play something I get "unable to cast this media is currently unavailable" on my Chromecast. Starting it manually works.

Hi, thanks a lot for your code! I managed to connect to the Chromecast using pychromecast and to plexapi, but unfortunately every time I try to play something I get "unable to cast this media is currently unavailable" on my Chromecast. Starting it manually works.

Do you have any ideas?

Hmmm... not really, other than possibly you're calling or referencing the episode wrong from plexapi?

Another question: Do I need to connect a client first? I.e. do I have to connect to Plex with a browser or the app before I can do anything?

To answer your second question first: No, the controller should connect itself just find with no browser involved. The first question is more complicated... mainly because your code works for me.... so long as you are trying to get the first unwatched movie in the movie section. I didn't have any marked as "unwatched" to start with and it fell over, but once I marked one as unwatched, that code ran for me fine.

To answer your second question first: No, the controller should connect itself just find with no browser involved. The first question is more complicated... mainly because your code works for me.... so long as you are trying to get the first unwatched movie in the movie section. I didn't have any marked as "unwatched" to start with and it fell over, but once I marked one as unwatched, that code ran for me fine.

Thanks for the reply, it works now. Connecting directly to the plex server in the local network doesn't seem to work. What worked is connecting over plex.tv as shown here... I thought that it doesn't matter.

Anyway, what I was hoping for is that after connecting it would show up as a device / client in the Plex app so I could control it from there (and from amazon echo), but it doesn't show up Do you think that would be possible? If I connect manually from a browser it shows up as "Plex Web (Chrome)".

Thanks for the reply, it works now. Connecting directly to the plex server in the local network doesn't seem to work. What worked is connecting over plex.tv as shown here... I thought that it doesn't matter.

Anyway, what I was hoping for is that after connecting it would show up as a device / client in the Plex app so I could control it from there (and from amazon echo), but it doesn't show up Do you think that would be possible? If I connect manually from a browser it shows up as "Plex Web (Chrome)".

Well, once you are telling it to play on the Chromecast, the Chromecast is the 'client,' not the python script. Personally, my setup is that IFTTT catches commands from my Home Assistant, and then over their "Maker" app, I send a command to a URL on my personal web server, which then sends a command to my Chromecast. I'd think what'd you need to do is get Alexa to send commands to the Chromecast in whatever way, not some other player? Maybe Alexa->IFTTT->Maker->Web Server->Python Script->Chromecast?

All that said, I think I remember seeing that Plex HAS an Alexa app at this point?

XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality.Are you a developer?