Closed zinefer closed 2 years ago
This is the name of the library section shown in the Plex interface. Is yours named "TV Shows"?
Example:
plex documentation plex source (message by IssueLinks)
Just to note that I tested your payload in my local setup and it played the most recently added episode in my library without issue.
I'm fairly sure I'm correctly referencing everything.
Lovelace UI:
Again with a different library:
service: media_player.play_media
data:
entity_id: media_player.plex_plex_for_roku_den_roku
media_content_id: >-
{ "library_name": "Movies", "sort": "addedAt:desc", "maxresults": 1 }
media_content_type: movie
[140650785212112] Error handling message: Media could not be found: { "library_name": "Movies", "sort": "addedAt:desc", "maxresults": 1 } websocket_api script: Error executing script. Error for call_service at pos 1: Media could not be found: { "library_name": "Movies", "sort": "addedAt:desc", "maxresults": 1 } Library 'Movies' not found
Are these local libraries or shared from a remote server?
Sorry, I don't understand the question.
These libraries exist on my Plex Server that is being pointed at by the Plex Media Server integration. The lovelace UI can see them, their contents and it can play anything in there. It just doesn't work with the service call.
Remote in reference to what? Plex is running in a separate container to Home Assistant, does that mean remote? Plex and Home Assistant are running on the same host machine and in the same local network, does that make them local?
Edit: I'm looking for a way to add remote libraries and I'm also not seeing anything like that. I think these are just average libraries.
Sorry, I was asking if the "TV Shows" and "Movies" libraries are hosted on the Plex server associated with the configured Plex integration. It sounds like that's the case.
Since the library names aren't matching, we can check the API response with the following call to see how things look:
$ curl 'http://<PLEX_SERVER_IP>:32400/library/sections?X-Plex-Token=<PLEX_TOKEN>'
Well, that explains that! Now how did it happen....
<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="4" allowSync="0" title1="Plex Library">
<Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/1/composite/1645027131" filters="1" refreshing="0" thumb="/:/resources/movie.png" key="1" type="movie" title=" Movies" agent="tv.plex.agents.movie" scanner="Plex Movie" language="en-US" uuid="20
98e655-1cb9-42f6-82bb-20ac661088e1" updatedAt="1620318187" createdAt="1585888131" scannedAt="1645027131" content="1" directory="1" contentChangedAt="505816035106756865" hidden="0">
<Location id="1" path="/mnt/media/movies" />
</Directory>
<Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/3/composite/1645027131" filters="1" refreshing="0" thumb="/:/resources/movie.png" key="3" type="movie" title=" Sports" agent="tv.plex.agents.movie" scanner="Plex Movie" language="en-US" uuid="556c
8622-be4a-4e35-ba3b-180da427184b" updatedAt="1620318190" createdAt="1586071802" scannedAt="1645027131" content="1" directory="1" contentChangedAt="505816035107131041" hidden="0">
<Location id="3" path="/mnt/media/sports" />
</Directory>
<Directory allowSync="1" art="/:/resources/show-fanart.jpg" composite="/library/sections/2/composite/1645040014" filters="1" refreshing="0" thumb="/:/resources/show.png" key="2" type="show" title=" TV Shows" agent="tv.plex.agents.series" scanner="Plex TV Series" language="en-US" uuid=
"31e3a17a-82e9-43bc-93c4-4605d792308a" updatedAt="1644854211" createdAt="1585888156" scannedAt="1645040014" content="1" directory="1" contentChangedAt="505816035107161262" hidden="0">
<Location id="2" path="/mnt/media/tv" />
</Directory>
</MediaContainer>
I wonder if including a list of all the existing libraries in the error message could have helped me help myself... xD
Not quite what I expected... 😄
If you strip the leading spaces does it start working?
Yes but strangely it appears to play a TV Show that is not in that library now...? This was a reduced version of the query I want to run for my automation so I will go try that.
Okay, so it is mostly working, although it was playing a TV Show I do not own when I did not specify a show_name
.
I also am having other problems related to inProgress
and unwatched
filtering though. Should I open a new issue for those?
By the way, I really appreciate all the help you've given me. 🙇
Okay, so it is mostly working, although it was playing a TV Show I do not own when I did not specify a
show_name
.
I'm not quite sure what you mean. It's playing media that doesn't exist in your library?
I also am having other problems related to
inProgress
andunwatched
filtering though. Should I open a new issue for those?
Probably better to keep things separate in a new issue. I'll probably update the error message to include the available library names as you suggested and that will close this issue. (And maybe strip the whitespace out of library names 😬)
By the way, I really appreciate all the help you've given me. 🙇
Of course, hopefully we can get everything running smoothly. 👍
I was looking over my notes today when I came across this section:
#### Libraries
Use spaces to order your libraries. More spaces is higher in the list. Spaces are hidden on display.
This must have been a recommended strategy by someone.... 🤔
https://old.reddit.com/r/PleX/comments/9adjku/change_order_of_libraries/e4v5q5c/
Yeah, apparently this isn't uncommon.
Huh, ok. Thanks for sharing the link, it does work as described and I can see the usefulness.
Here's a PR to address this in the underlying library so you don't need to rename your libraries or use hacky searches: https://github.com/pkkid/python-plexapi/pull/888
The problem
The UI can see all my libraries but
media_player.play_media
cannot.I've tried to enable debug logging by adding:
To my configuration.yaml but it does not seem to be having an effect.
What version of Home Assistant Core has the issue?
core-2022.2.6
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
Plex
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response