How can I have my GoogleTV open Plex and play a random episode from a TV series?

So I’ve created a ESP32 NFC Tag reader and I’ve created NFC tags that when the tag is scanned will cast a random episode of whatever the tag is to my GoogleTV. This is for my daughter whose soon to be two.

It’s working somewhat well, however since I’m using cast functionality vs opening the Plex app on the Google TV, I’m falling into an issue where button actions such as media_player.media_next_track won’t work with the cast function.

What I would like to do is to be able to actually open the Plex app on the google TV and then start the episode that way instead of casting, for additional button functionality.

Where I’m failing is how exactly to call on media_player to open the app and play the episode instead of casting.

I’ve tried Android TV Remote and I can get it to open the plex app, but past that I’m not sure how to pass it values like the TV show title or shuffle / random.

I also have the Google Cast integration in Home Assistant and can see additional attributes, but I’m not sure if it will ever open the actual plex app on googletv or just continue to attempt to cast.

Any thoughts or examples if you have it working?

Check the Plex docs for advanced searches for how to choose random episodes from a show: Plex Media Server - Home Assistant

The Plex Cast app has a limitation where it does not support native Cast prev/next skip controls. Using the native Plex app should work fine as long as you have a way to launch it reliably first. You may also need to call the Plex scan clients button service after launching it so that the Plex integration can send commands to it as a proper client.

1 Like

That was very helpful and gets me a bit further in my search. I’m able to control episodes through the plex server integration and I cobbled together a way to get it to play a random episode, but it’s very hacky and a little slow due to having to emulate button presses.

Few things:

  1. I noticed I need to turn on the TV first before it will pass to open the plex app

  2. I’d like to just open the app and select the user, however I have to use the DPAD_CENTER command to select the user, and for whatever reason on the first pass of the DPAD_CENTER command the plex app “refreshes” and shows a splash screen for a second and then shows the user login screen again, so I had to add a second DPAD_CENTER command.

  3. Like you said, I had to add the scan clients button and added a slight delay before starting an episode

Here’s what I created in node red

[{"id":"ec0b5a5e3fa0097d","type":"tab","label":"Launch Episode Example Flow","disabled":false,"info":"","env":[]},{"id":"5c3bb4a2b88906e8","type":"api-call-service","z":"ec0b5a5e3fa0097d","name":"Turn on TV","server":"2e31528c.f3973e","version":5,"debugenabled":false,"domain":"remote","service":"turn_on","areaId":[],"deviceId":[],"entityId":["remote.living_room_tv"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":270,"y":200,"wires":[["0d34a8f5ccda601c"]]},{"id":"4c737958f0e2614a","type":"inject","z":"ec0b5a5e3fa0097d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":200,"wires":[["5c3bb4a2b88906e8"]]},{"id":"15bc829bbb910da7","type":"api-call-service","z":"ec0b5a5e3fa0097d","name":"Start Plex","server":"2e31528c.f3973e","version":5,"debugenabled":false,"domain":"remote","service":"turn_on","areaId":[],"deviceId":[],"entityId":["remote.living_room_tv"],"data":"{\"activity\":\"plex://\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":200,"wires":[["bd72840e18dd0362"]]},{"id":"0d34a8f5ccda601c","type":"delay","z":"ec0b5a5e3fa0097d","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":500,"y":200,"wires":[["15bc829bbb910da7"]]},{"id":"bd72840e18dd0362","type":"delay","z":"ec0b5a5e3fa0097d","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":820,"y":200,"wires":[["7fce9c44b2987647"]]},{"id":"e183f2267d9c20a8","type":"api-call-service","z":"ec0b5a5e3fa0097d","name":"Play Bluey","server":"2e31528c.f3973e","version":5,"debugenabled":false,"domain":"media_player","service":"play_media","areaId":[],"deviceId":[],"entityId":["media_player.plex_annabel_plex_for_android_tv_chromecast_google_tv"],"data":"{\t    \"media_content_type\": \"EPISODE\",\t    \"media_content_id\": \"{\\\"library_name\\\": \\\"TV Shows\\\", \\\"show_name\\\": \\\"Bluey (2018)\\\", \\\"shuffle\\\": \\\"1\\\",\\\"maxresults\\\": 1 }\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":540,"wires":[["fcbdfa329a6008f6"]]},{"id":"fcbdfa329a6008f6","type":"debug","z":"ec0b5a5e3fa0097d","name":"debug 72","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":540,"wires":[]},{"id":"7fce9c44b2987647","type":"api-call-service","z":"ec0b5a5e3fa0097d","name":"DPAD_CENTER","server":"2e31528c.f3973e","version":5,"debugenabled":false,"domain":"remote","service":"send_command","areaId":[],"deviceId":[],"entityId":["remote.living_room_tv"],"data":"{\"command\":\"DPAD_CENTER\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1000,"y":200,"wires":[["d2982d3625c67355"]]},{"id":"d2982d3625c67355","type":"delay","z":"ec0b5a5e3fa0097d","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1180,"y":200,"wires":[["09af96fb3a23b84f"]]},{"id":"09af96fb3a23b84f","type":"api-call-service","z":"ec0b5a5e3fa0097d","name":"DPAD_CENTER","server":"2e31528c.f3973e","version":5,"debugenabled":false,"domain":"remote","service":"send_command","areaId":[],"deviceId":[],"entityId":["remote.living_room_tv"],"data":"{\"command\":\"DPAD_CENTER\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1340,"y":200,"wires":[["5168dc643dad0d87"]]},{"id":"5168dc643dad0d87","type":"delay","z":"ec0b5a5e3fa0097d","name":"","pauseType":"delay","timeout":"6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":980,"y":360,"wires":[["64e4ba354fcda058"]]},{"id":"64e4ba354fcda058","type":"api-call-service","z":"ec0b5a5e3fa0097d","name":"Scan for Plex Clients","server":"2e31528c.f3973e","version":5,"debugenabled":false,"domain":"button","service":"press","areaId":[],"deviceId":[],"entityId":["button.scan_clients_octoplex"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1200,"y":360,"wires":[["12efaea9f8c550f0"]]},{"id":"12efaea9f8c550f0","type":"delay","z":"ec0b5a5e3fa0097d","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1400,"y":360,"wires":[["e183f2267d9c20a8"]]},{"id":"2e31528c.f3973e","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]