NemesisRE / sensor.plex_recently_added

▶️ Plex component to feed Upcoming Media Card.
Apache License 2.0
18 stars 3 forks source link

No data being pulled #1

Open Gibletron opened 2 years ago

Gibletron commented 2 years ago

Describe the Bug Whatever settings I choose, I am only seeing that plex is "online" but not retrieving any additional attributes

The Error Update of sensor.plex_recently_added is taking over 10 seconds

Indicate if you followed all steps in the troubleshooting doc I did! Inputting the URL with the token, and plex address/port returns an XML

What data does the sensor display if any? Status: online Attributes:

What displays when visiting the API URL from the troubleshooting guide? Just a regular XML sheet, containing recently added media

Does the default Home Assistant Plex component work for you? Yes it does

Home Assistant Version Home Assistant 2022.9.7

Additional Context I have tested with the local URL, local IP and public URL I have tested with port 32400 and through my reverse proxy over port 443 I have tested with ssl and ssl_cert set to true and false (false for internal url and ip, true for public url) With all the above I can use the troubleshooting API URL and it always works. I have tested the troubleshooting API url from ha core through curl, which always works I have restarted HA Core between every test I have tried multiple (image) output folder I have reinstalled the integration multiple times I have tried ping and nslookup from the ha core container to the plex server, which both work without issue.

Gibletron commented 2 years ago

Today, I decided to create 27 seperate sensors, with all combinations/permutations I can think of: Host: Internal IP, Internal FQDN, External FQDN Port: 80, 443, 32400 ssl: true/false ssl_cert: true/false

Then I tried all permutations of the plex_token that I can find.. (when finding it through the IP, through internal FQDN, through external FQDN, etc) I just cannot get it to work

Gibletron commented 2 years ago

The debug logs contain:

2022-10-04 23:23:24.903 ERROR (MainThread) [homeassistant.components.sensor] plex_recently_added: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 493, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 703, in async_device_update
await task
File "/config/custom_components/plex_recently_added/sensor.py", line 254, in async_update
libraries = json.loads(libraries)
File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.10/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 5 (char 4)
Gibletron commented 2 years ago

If I understand correctly it breaks on the line where it's retrieving all the libraries from my Plex instance. However, when I try the same command, it retrieves a (correct) xml file

http://[IP]:[PORT]/library/sections/all?X-Plex-Token=[token]
<MediaContainer size="6" allowSync="0" title1="Plex Library">
<Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/3/composite/1664914974" filters="1" refreshing="0" thumb="/:/resources/movie.png" key="3" type="movie" title="Comedies" agent="tv.plex.agents.movie" scanner="Plex Movie" language="en-US" uuid="da9d23b1-eea0-457e-99e5-9c0d5d6cd7db" updatedAt="1663264414" createdAt="1663264414" scannedAt="1664914974" content="1" directory="1" contentChangedAt="40996" hidden="0">
<Location id="3" path="/media/Comedies"/>
</Directory>
<Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/1/composite/1664914998" 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="7e8ddd3f-9d5c-48f6-9ef2-dedff64fefd0" updatedAt="1663264129" createdAt="1663263885" scannedAt="1664914998" content="1" directory="1" contentChangedAt="36453065" hidden="0">
<Location id="1" path="/media/Movies"/>
</Directory>
<Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/2/composite/1664914999" filters="1" refreshing="0" thumb="/:/resources/movie.png" key="2" type="movie" title="Movies-4K" agent="tv.plex.agents.movie" scanner="Plex Movie" language="en-US" uuid="6045bd7a-3dab-4b3d-9a54-2531dc904012" updatedAt="1663264019" createdAt="1663264019" scannedAt="1664914999" content="1" directory="1" contentChangedAt="39396" hidden="0">
<Location id="2" path="/media/Movies-4K"/>
</Directory>
<Directory allowSync="1" art="/:/resources/show-fanart.jpg" composite="/library/sections/6/composite/1664917915" filters="1" refreshing="0" thumb="/:/resources/show.png" key="6" type="show" title="Anime" agent="tv.plex.agents.series" scanner="Plex TV Series" language="en-US" uuid="bdda2812-f296-4430-808b-061733718596" updatedAt="1663264662" createdAt="1663264662" scannedAt="1664917915" content="1" directory="1" contentChangedAt="36481277" hidden="0">
<Location id="6" path="/media/Anime"/>
</Directory>
<Directory allowSync="1" art="/:/resources/show-fanart.jpg" composite="/library/sections/5/composite/1664917948" filters="1" refreshing="0" thumb="/:/resources/show.png" key="5" type="show" title="Reality Shows" agent="tv.plex.agents.series" scanner="Plex TV Series" language="en-US" uuid="ea272fe3-7b65-4706-b77e-978b26ecc724" updatedAt="1663264624" createdAt="1663264624" scannedAt="1664917948" content="1" directory="1" contentChangedAt="36513273" hidden="0">
<Location id="5" path="/media/Reality_Shows"/>
</Directory>
<Directory allowSync="1" art="/:/resources/show-fanart.jpg" composite="/library/sections/4/composite/1664917907" filters="1" refreshing="0" thumb="/:/resources/show.png" key="4" type="show" title="TV Shows" agent="tv.plex.agents.series" scanner="Plex TV Series" language="en-US" uuid="fbe4da8b-f213-4d2b-962b-683d5840f6fa" updatedAt="1663264589" createdAt="1663264589" scannedAt="1664917907" content="1" directory="1" contentChangedAt="36516038" hidden="0">
<Location id="4" path="/media/Series"/>
</Directory>
</MediaContainer>