custom-components / sensor.plex_recently_added

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

Multiple sensors causes missing images #34

Closed tamet83 closed 4 years ago

tamet83 commented 4 years ago

Describe the Bug I configured two sensors: one for movies and one for tv shows. The second one doesn't shows on lovelace.

The Error Actually the system doesn't give me specific error. I have just the warning that I'm using a custom component.

Indicate if you followed all steps in the troubleshooting doc Yes

What data does the sensor display if any? Display normally. In particular TV shows gives this data:

data: >-
  [{"title_default": "$title", "line1_default": "$episode", "line2_default":
  "$release", "line3_default": "$number - $rating - $runtime", "line4_default":
  "$genres", "icon": "mdi:eye-off"}]
friendly_name: Serie

What displays when visiting the API URL from the troubleshooting guide? Displays the normal xml code of the recently added page

Does the default Home Assistant Plex component work for you? Do you mean the plex sensor? If it so, yes it correctly retrive information from my server.

Home Assistant Version Home Assistant 0.106.6

Additional Context As you can see, the movies section works fine, but the TV shows doesn't.

Upcoming

maykar commented 4 years ago

What does your config look like for both the components and cards?

tamet83 commented 4 years ago

Hi, following the sensors code:

- platform: plex_recently_added
  name: Film
  token: !secret plex_token
  host: !secret plex_host
  port: !secret plex_port
  section_types:
    - movie
  max: 4
  download_images: true
  img_dir: '/plex_artwork/'
  # ssl: false
  # ssl_cert: false

- platform: plex_recently_added
  name: Serie
  token: !secret plex_token
  host: !secret plex_host
  port: !secret plex_port
  section_types:
    - show
  max: 4
  download_images: true
  img_dir: '/plex_artwork/'
  # ssl: false
  # ssl_cert: false

Instead here the card code:

title: Film e Serie TV in uscita
path: upcoming
icon: mdi:filmstrip
background: var(--background-image)
cards:
#TV SHOW CODE
  - type: custom:upcoming-media-card
    entity: sensor.serie
    title: Plex puntate aggiunte di recente
    image_style: fanart
    flag: false
    date: ddmm
    border_color: '#222222'
    accent_color: '#222222'
    box_shadows: false
#FILM CODE
  - type: custom:upcoming-media-card
    entity: sensor.film
    title: Plex Film aggiunti di recente
    image_style: fanart
    flag: false
    date: ddmm
    border_color: '#222222'
    accent_color: '#222222'
    box_shadows: false
maykar commented 4 years ago

Looks good, try white listing your home assistant page in your browsers ad blocker.

https://community.home-assistant.io/t/lovelace-upcoming-media-card/66562/585

tamet83 commented 4 years ago

I don't have ad bloker on my browser. I have PiHole, i tried to white list my internal Home Assistant IP and the external domain i use to connect from remote. But it doesn't work. I have the same extat problem on every device I use: PC and iDevice

maykar commented 4 years ago

Hmmm...Does sensor.serie show a list of shows like sensor.film does or does it just show what you shared above?

tamet83 commented 4 years ago

I see the XML code of the page. Is it correct?

tamet83 commented 4 years ago

Hmmm...Does sensor.serie show a list of shows like sensor.film does or does it just show what you shared above?

This is the output of the sensor.serie:

data: >-
  [{"title_default": "$title", "line1_default": "$episode", "line2_default":
  "$release", "line3_default": "$number - $rating - $runtime", "line4_default":
  "$genres", "icon": "mdi:eye-off"}]
friendly_name: Serie

Instead this one is the sensor.film

data: >-
  [{"title_default": "$title", "line1_default": "$episode", "line2_default":
  "$release", "line3_default": "$number - $rating - $runtime", "line4_default":
  "$genres", "icon": "mdi:eye-off"}, {"airdate": "2020-03-15T22:54:03Z",
  "aired": "2019-09-12", "release": "$day, $date $time", "flag": true, "title":
  "Hustlers", "episode": "", "runtime": 110, "studio": "Nuyorican Productions",
  "genres": "Comedy, Crime", "rating": "\u2605 6.3", "poster":
  "/local/plex_artwork/p4088.jpg", "fanart": "/local/plex_artwork/f4088.jpg"},
  {"airdate": "2020-03-06T07:07:25Z", "aired": "2019-11-27", "release": "$day,
  $date $time", "flag": true, "title": "Knives Out", "episode": "", "runtime":
  130, "studio": "Lionsgate", "genres": "Comedy, Crime", "rating": "\u2605 7.8",
  "poster": "/local/plex_artwork/p4049.jpg", "fanart":
  "/local/plex_artwork/f4049.jpg"}, {"airdate": "2020-03-04T18:41:48Z", "aired":
  "1998-12-15", "release": "$day, $date $time", "flag": true, "title": "The
  Prince of Egypt", "episode": "", "runtime": 94, "studio": "DreamWorks
  Pictures", "genres": "Animation, Adventure", "rating": "\u2605 7.1", "poster":
  "/local/plex_artwork/p4043.jpg", "fanart": "/local/plex_artwork/f4043.jpg"},
  {"airdate": "2020-02-29T20:45:04Z", "aired": "2013-12-18", "release": "$day,
  $date $time", "flag": true, "title": "The Secret Life of Walter Mitty",
  "episode": "", "runtime": 114, "studio": "New Line Cinema", "genres": "Comedy,
  Drama", "rating": "\u2605 7.1", "poster": "/local/plex_artwork/p3993.jpg",
  "fanart": "/local/plex_artwork/f3993.jpg"}]
friendly_name: Film
kdoh82 commented 4 years ago

I'm having the same issue but I'm not seeing movie photos but having no issues with TV shows. The sensor is updating the movies that are added to plex perfectly fine but I just don't see any of the poster photos.

When I inspect the element, it looks like the UI is trying to load an image that doesn't exist in the local download folder. When I switch the movie sensor to "download_images: false" it pulls straight from my plex server's local IP address and shows up fine.

What other info would you need to help t-shoot?

Adam-North commented 4 years ago

I'm having the same issue but I'm not seeing movie photos but having no issues with TV shows. The sensor is updating the movies that are added to plex perfectly fine but I just don't see any of the poster photos.

I'm having the same issue. It tries to load images which do not exist in the directory.

maykar commented 4 years ago

Thanks all for the helpful info. The component auto deletes images no longer in the list, but I didn't account for this when multiple sensors were added. This causes the multiple sensors to fight each other and delete what isn't in their list. Easy enough fix and I should be able to get to it soon.

chansters commented 4 years ago

Thanks all for the helpful info. The component auto deletes images no longer in the list, but I didn't account for this when multiple sensors were added. This causes the multiple sensors to fight each other and delete what isn't in their list. Easy enough fix and I should be able to get to it soon.

I'm having the same issue. Is there a workaround or fix for this ?

mkanet commented 4 years ago

Thank you for the version 0.4.1 update. This issue is now resolved!

chansters commented 4 years ago

Thank you for the version 0.4.1 update. This issue is now resolved!

Awesome ! Not sure why I have a different version number (0.3.0) but just installed the latest update and it fixed it for me as well. Thanks !!

tamet83 commented 4 years ago

Hi @maykar I’m still experiencing the same issue. I have the version 0.3.2 Thanks for your help

maykar commented 4 years ago

@tamet83 Please,share your config for the cards and your sensors. Is there a folder for each sensor in /www/upcoming-media-card-images/ ? Those folders should be automatically created and contain your images.

tamet83 commented 4 years ago

@maykar thank you. I confirm that i have the two folder. But i noticed also that some images are outside the folders as you can see in the screenshot: Folders

Here is the code:

- platform: plex_recently_added
  name: Film
  token: !secret plex_token
  host: !secret plex_host
  port: !secret plex_port
  section_types:
    - movie
  max: 4
  download_images: true
  img_dir: '/plex_artwork/'
  # ssl: false
  # ssl_cert: false

- platform: plex_recently_added
  name: Serie
  token: !secret plex_token
  host: !secret plex_host
  port: !secret plex_port
  section_types:
    - show
  max: 4
  download_images: true
  img_dir: '/plex_artwork/'

I just noticed that maybe I have to change the img_dir. In case, I'm really sorry, I missed it.

tamet83 commented 4 years ago

Hi @maykar i changed the img_dir path and now sems to work. Although I noticed that the folders are still empty. All the images are stored in the parent folder alla together as you can see on the screenshot attached:

Folders_2

I'm not sure this is the correct behavior. The two sensors folders are still necessary?

maykar commented 4 years ago

You can always safely delete the images in that folder, they will be automatically downloaded as needed. There may have been images left over from the update that changed things to be in separate folders for multiple sensors.

The reason you are now getting all the images outside of the folders is because you forgot to end the img_dir path with a /. Image files always start with and "f" or a "p", but since you left out that slash it is appending what would be the folder name to the beginning of the file. Which won't cause any issues, but the folders will still always be created.

If you'd like them to be in the folder "plex_artwork', put this back in your config img_dir: '/plex_artwork/' restart HA and then delete all folders and images associated with this component. It will then automatically create the correct folders and files in less than a minute.

maykar commented 4 years ago

The reason you can end up with left over files and/or folders is for safety. The component delete's images it no longer needs that match the way it names the files contained in the folders set in config. It can only know what your current setup is, not what it used to be. So if you remove a sensor or rename it, the component won't delete the files. This is just in case someone decides to store something in those same folders, I don't want to delete anyone's files.

tamet83 commented 4 years ago

Many thanks for you help and explanation. Now everything works :)