Trouble playing Plex media from service call

I’m trying to set up a couple scripts to play videos from Plex on our fire stick with the Plex app, but I’m not having any luck as the media_player.play_media service just keeps telling me the media could not be found:

entity_id: media_player.plex_living_room_fire_stick
media_content_type: video
media_content_id: "{ \"library_name\": \"Movies\", \"video_name\": \"Trolls\", \"shuffle\": 0 }"

Media could not be found: { "library_name": "Movies", "video_name": "Trolls", "shuffle": 0 }

entity_id: media_player.plex_living_room_fire_stick
media_content_type: episode
media_content_id: { \"library_name\": \"TV Shows\", \"show_name\": \"Paw Patrol\", \"season_number\": 1, \"episode_number\": 1, \"shuffle\": 0 }

Media could not be found: { "library_name" : "TV Shows", "show_name" : "Paw Patrol", "season_number" : 1, "episode_number" : 1, "shuffle": "0" }

and so on for a handful of shows and movies I tried. Library name matches the Plex server, and movie/show titles match what shows up in the Plex app. What am I missing?

The docs show media_content_type in ALLCAPS. I don’t know if that is needed, worth a try.

PS it is specified in the source as ALLCAPS.

Yes, it’s unfortunately case sensitive at the moment. If you use all caps and you’re still seeing the “Media could not be found:” error, that implies that the Plex server simply can’t find the media you’re requesting. Movies are usually the simplest test.

PS: The shuffle parameter is optional in recent versions but the docs haven’t been updated to reflect this yet. It’ll default to “0” if not included.

Tried it again yesterday and made sure I was using all caps for media type and it seems to be working now, so I think we can call this resolved.

1 Like

hey @cgarwood , i am also strugging, cant get it to work… tried also all caps
like video VIDEO movie MOVIE
for title i tried Aladdin or

always same error

example

entity_id: media_player.plex_plex_web_chrome
media_content_type: MOVIE
media_content_id: '{ "library_name" : "Movies", "video_name" : "Aladdin (1992)", "shuffle": "0" }'
2020-03-28 13:44:09 ERROR (SyncWorker_4) [homeassistant.components.plex.media_player] Media could not be found: { "library_name" : "Movies", "video_name" : "Aladdin", "shuffle": "0" }
2020-03-28 13:44:42 ERROR (SyncWorker_0) [homeassistant.components.plex.media_player] Media could not be found: { "library_name" : "Movies", "video_name" : "Aladdin (1992)", "shuffle": "0" }

if i watch at the state of a media player when i run manually i see:

media_content_id: 6777
media_content_type: movie
media_duration: 7678
media_position: 0
media_position_updated_at: 2020-03-28T12:43:11.530222+00:00
media_title: Aladdin (1992)
app_name: Movies
media_content_rating: G
session_username: Fabio.Pergola
media_library_name: Movies

if i do from a script, to actually see the movie name :

movies = plex.library.section('Movies')
for video in movies.search(unwatched=True):
    print(video.title)

the correct movie result =

Aladdin
and not :

Aladdin (1992)

but tried both…

can you help ?

pff; cant find out, this my test script…

always : media can not be found

a_test_plex:
  alias: 1 TEST PLEX
  sequence:
  - service: media_player.play_media
    data:
      entity_id: media_player.plex_plex_web_chrome
      media_content_id: "{ \"library_name\": \"Movies\", \"video_name\": \"Terminator\", \"shuffle\": \"0\" }"
      media_content_type: MOVIE

What HA version are you running? Didn’t see it mentioned in your posts.

latest one, running 107.6

this my setup :

plex:
  host: !secret plex_ip
  port: !secret plex_port
  token: !secret plex_token
  ssl: false
  verify_ssl: false
  media_player:
    use_episode_art: true
    ignore_new_shared_users: false

it works, i see media players being created, i can stop/play/resume from there
just from a service call it isnt working

Have a look in formatting in the first post, especially the use of backslash before quotation mark,

\"

It looks like the service call is fine, but the Plex server isn’t finding the media as requested. Let me see if I can reproduce this locally.

Is plexapi 3.3.0 important? Is it possible that it doesn’t work when an older version is installed?

i have also this component custom active :

as you can see in the manifest they point to =


    "git+https://github.com/pkkid/[email protected]#plexapi==9.9.9"

not sure what is is, no idea what that version is about …
but after unloading that custom and doing a rebuild of my core, the script works …

can that be the solution?

Yep, it looks like that custom component is pulling down a different version of plexapi and replacing the standard dependency version. I’ll have to see what’s different in the behavior at that commit vs the expected 3.3.0 release.

To confirm, when reverting to 3.3.0 everything works as expected?

Yeah, it works on my Samsung TV, but it doesn’t work when u use chrome player… If I fire it to my chrome webplayer, it doesn’t do anything, I don’t see an error either…

Is that commit newer?

Yes, you had been running a newer commit than 3.3.0. That release wasn’t tagged in github but was published to pypi on Nov 11 (commit).

Chrome was probably working on the newer version as it included this PR.

Since HA only allows dependencies to use published releases, we need to wait for a newer release to come out as 3.3.0 is the latest. I’ve already requested this and hopefully we’ll have it soon.

Ok, but I don’t understand completely…

How come I was not able to play media with that newer commit?

Why you were getting “Media could not be found”? Not sure yet, but now we’ve cleared up some of the other confusion. I’ll need to test the integration before bumping to a new version.

yes, indeed the media could not be found message

but still trying to understand , what version do you want to bump ? the latests 3.3.0 is already merged? i dont see a new version?

this one is already merged? https://github.com/home-assistant/core/pull/28709

Also is it possible to see what version is actually loaded/installed in HA?