PLEX latest movies click to play

Is there a ways to have the poster of the recently added movies and play that movie in a specific player?

Would like to have 1 page on the dashboard with the latest movie posters where every poster is clickable and deploys the action of playing that movie plus a automation.

Any guidance would be great! thanks :grin:

The new media browser functionality is available from Media Control cards. There’s a Recently Added section as you open it up. Clicking on any of those will play it on the device if supported. There’s also library-specific recently added and on deck sections if you drill down deeper.

Hi so far so good:
got sensors with the name of the movie , image and the flag and could put them as picture cards inside a picture elements card so i can arrange them. but when it came to the action part it didn’t work , i was reading and all seams good. maybe take a quick look and see if there is something wrong here?

tap_action:
      entity_id: media_player.plex_tv_livingroom
      media_content_type: movie
      media_content_id: '{ "library_name": "Movies", "title": "Date With an Angel" }'

type: picture-elements
image: /local/pictures/hc-courtines.jpg
elements:
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_1
    card:
      type: picture
      image: '${states[''sensor.plex_recently_movies_poster_1''].state }'
    tap_action:
      entity_id: media_player.plex_tv_livingroom
      media_content_type: movie
      media_content_id: '{ "library_name": "Movies", "title": "Date With an Angel" }'
    style:
      top: 44%
      left: 12%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_2
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_2''].state }'
    style:
      top: 44%
      left: 30%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_3
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_3''].state }'
    style:
      top: 44%
      left: 48%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_4
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_4''].state }'
    style:
      top: 44%
      left: 66%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_5
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_5''].state }'
    style:
      top: 44%
      left: 85%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_6
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_6''].state }'
    style:
      top: 82%
      left: 12%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_7
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_7''].state }'
    style:
      top: 82%
      left: 30%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_8
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_8''].state }'
    style:
      top: 82%
      left: 48%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_9
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_9''].state }'
    style:
      top: 82%
      left: 66%
      width: 13%
      border: 2px solid gold
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_10
    card:
      type: picture
      elements:
        - state-icon: 'mdi:plex'
      image: '${states[''sensor.plex_recently_movies_poster_10''].state }'
    style:
      top: 82%
      left: 85%
      width: 13%
      border: 2px solid gold

The player must be running and available. Enabling debug logs with the logger.set_level service and home assistant.components.plex: debug as the payload should give you more context.

thanks for all your help, its alomst there
its phaying but in the tap_action, media_content_is is showing me a indent error, its works fin in the developers tools template:

"{ "library_name": "Movies", "title": "{{ state_attr('sensor.plex_recently_added', 'data')[1]['title'] }}", "Year": "{% set text = state_attr('sensor.plex_recently_added', 'data')[1]['aired'] %}{{ text.split('-')[0].strip()}}" }"

i get the correct reponse:
“{ “library_name”: “Movies”, “title”: “Date With an Angel”, “Year”: “1987” }”

but in the card it wont work (created a separate picture card)

type: 'custom:config-template-card'
entities:
      - sensor.plex_recently_added
card:
  type: 'custom:hui-picture-card'
  tiltle: Movie 1
  image: '${states[''sensor.plex_recently_movies_poster_1''].state }'
  tap_action:
    action: call-service
    service: media_player.play_media
    service_data:
      entity_id: media_player.plex_tv_livingroom
      media_content_type: movie
      media_content_id: '$"{ "library_name": "Movies", "title": "{{ state_attr('sensor.plex_recently_added', 'data')[1]['title'] }}", "Year": "{% set text = state_attr('sensor.plex_recently_added', 'data')[1]['aired'] %}{{ text.split('-')[0].strip()}}" }" '
    style:
      top: 44%
      left: 12%
      width: 13%
      border: 2px solid gold

can you help me point out where im am doing the wrong ident?

thanks

this is how i think the card should be but still cant make it to work

type: picture-elements
image: /local/pictures/hc-courtines.jpg
elements:
  - type: 'custom:config-template-card'
    entities:
      - sensor.plex_recently_movies_poster_1
    card:
      type: 'custom:hui-picture-card'
      image: '${{ state_attr('sensor.plex_recently_added', 'data')[1]['poster'] }}'
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: '$"{ "library_name": "Movies", "title": "{{ state_attr('sensor.plex_recently_added', 'data')[1]['title'] }}", "Year": "{{ state_attr('sensor.plex_recently_added', 'data')[1]['aired'].split("-")[0] }}" }" '
    style:
        top: 44%
        left: 12%
        width: 13%
        border: 2px solid goldtype or paste code here

where
this:
“{ “library_name”: “Movies”, “title”: “{{ state_attr(‘sensor.plex_recently_added’, ‘data’)[1][‘title’] }}”, “Year”: “{{ state_attr(‘sensor.plex_recently_added’, ‘data’)[1][‘aired’].split(”-”)[0] }}" }"
gives me:
“{ “library_name”: “Movies”, “title”: “Date With an Angel”, “Year”: “1987” }”

and"{{ state_attr(‘sensor.plex_recently_added’, ‘data’)[1][‘poster’] }}"
gives me:
“/local/upcoming-media-card-images/plex/Plex_Recently_Added/p173500.jpg”

Anyone??

Hi Dingin,

Can you enlighten me from where you get the sensor.plex_recently_movies_poster_1 entity?

TIA

Hi,
I created template sensors extracted from the Plex Recently Added integration in HACS.
Here is the first set for the first movie

############################################
########### Home Cinema Sensors  ###########
############################################

  - platform: template
    sensors:
      plex_recently_movies_name_1:
        friendly_name: "Movie 1 name"
        icon_template: mdi:movie-roll
        value_template:  "{{ state_attr('sensor.recently_added_movies', 'data')[1]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_1:
        friendly_name: "Movie 1 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[1]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_1:
        friendly_name: "Movie 1 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[1]['fanart'] }}"
        
  - platform: template
    sensors:
      plex_recently_movies_flag_1:
        friendly_name: "Movie 1 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[1]['flag'] }}"
        
  - platform: template
    sensors:
      plex_recently_movies_year_1:
        friendly_name: "Movie 1 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[1]['aired'] %}{{ text.split('-')[0].strip()}}" 
        
  - platform: template
    sensors:
      plex_recently_movies_play_movie_1:
        friendly_name: "Movie 1 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_1')}}", "year": "{{states('sensor.plex_recently_movies_year_1') }}" }
        

Hope it helps you or let me know if you need more help.

Dingin

Did you ever get this going? I was looking for the same kind of thing.

yes i did, there is also a new integration plex mets home assistant you shpuld check it out

Could you share your final card where you got it working? I have the plex integration already.

Here is the card:

type: picture-elements
image: /local/pictures/hc-courtines.jpg
elements:
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_1
      - sensor.plex_recently_added
      - sensor.plex_recently_movies_play_movie_1
    card:
      type: custom:hui-picture-card
      tiltle: Movie 1
      image: ${states['sensor.plex_recently_movies_poster_1'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_1'].state  }
    style:
      top: 44%
      left: 30%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_2
      - sensor.plex_recently_added
      - sensor.plex_recently_movies_play_movie_2
    card:
      type: custom:hui-picture-card
      tiltle: Movie 2
      image: ${states['sensor.plex_recently_movies_poster_2'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_2'].state  }
    style:
      top: 44%
      left: 12%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_3
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_3'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_3'].state  }
    style:
      top: 44%
      left: 48%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_4
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_4'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_4'].state  }
    style:
      top: 44%
      left: 66%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_5
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_5'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_5'].state  }
    style:
      top: 44%
      left: 85%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_6
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_6'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_6'].state  }
    style:
      top: 82%
      left: 12%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_7
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_7'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_7'].state  }
    style:
      top: 82%
      left: 30%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_8
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_8'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_8'].state  }
    style:
      top: 82%
      left: 48%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_9
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_9'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_9'].state  }
    style:
      top: 82%
      left: 66%
      width: 13%
      border: 2px solid gold
  - type: custom:config-template-card
    entities:
      - sensor.plex_recently_movies_poster_10
    card:
      type: picture
      elements:
        - state-icon: mdi:plex
      image: ${states['sensor.plex_recently_movies_poster_10'].state }
      tap_action:
        action: call-service
        service: media_player.play_media
        service_data:
          entity_id: media_player.plex_for_samsung_tv_livingroom
          media_content_type: movie
          media_content_id: ${states['sensor.plex_recently_movies_play_movie_10'].state  }
    style:
      top: 82%
      left: 85%
      width: 13%
      border: 2px solid gold

1 Like

and here are the sensors, Just remember you need the Plex Recently Added from hacs, this is based on those sensors. you will get something like this:

hope it helps you. please share your final card image and config :smiley:

sensors:

############################################
########### Home Cinema Sensors  ###########
############################################

  - platform: template
    sensors:
      plex_recently_movies_name_1:
        friendly_name: "Movie 1 name"
        icon_template: mdi:movie-roll
        value_template:  "{{ state_attr('sensor.recently_added_movies', 'data')[1]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_1:
        friendly_name: "Movie 1 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[1]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_1:
        friendly_name: "Movie 1 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[1]['fanart'] }}"
        
  - platform: template
    sensors:
      plex_recently_movies_flag_1:
        friendly_name: "Movie 1 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[1]['flag'] }}"
        
  - platform: template
    sensors:
      plex_recently_movies_year_1:
        friendly_name: "Movie 1 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[1]['aired'] %}{{ text.split('-')[0].strip()}}" 
        
  - platform: template
    sensors:
      plex_recently_movies_play_movie_1:
        friendly_name: "Movie 1 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_1')}}", "year": "{{states('sensor.plex_recently_movies_year_1') }}" }
        

  - platform: template
    sensors:
      plex_recently_movies_name_2:
        friendly_name: "Movie 2 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[2]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_2:
        friendly_name: "Movie 2 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[2]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_2:
        friendly_name: "Movie 2 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[2]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_2:
        friendly_name: "Movie 2 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[2]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_2:
        friendly_name: "Movie 2 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[2]['aired'] %}{{ text.split('-')[0].strip()}}" 
        
        
  - platform: template
    sensors:
      plex_recently_movies_play_movie_2:
        friendly_name: "Movie 2 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_2')}}", "year": "{{states('sensor.plex_recently_movies_year_2') }}" }


  - platform: template
    sensors:
      plex_recently_movies_name_3:
        friendly_name: "Movie 3 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[3]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_3:
        friendly_name: "Movie 3 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[3]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_3:
        friendly_name: "Movie 3 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[3]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_3:
        friendly_name: "Movie 3 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[3]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_3:
        friendly_name: "Movie 3 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[3]['aired'] %}{{ text.split('-')[0].strip()}}" 
        

  - platform: template
    sensors:
      plex_recently_movies_play_movie_3:
        friendly_name: "Movie 3 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_3')}}", "year": "{{states('sensor.plex_recently_movies_year_3') }}" }

  - platform: template
    sensors:
      plex_recently_movies_name_4:
        friendly_name: "Movie 4 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[4]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_4:
        friendly_name: "Movie 4 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[4]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_4:
        friendly_name: "Movie 4 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[4]['fanart'] }}"
        
  - platform: template
    sensors:
      plex_recently_movies_flag_4:
        friendly_name: "Movie 4 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[4]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_4:
        friendly_name: "Movie 4 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[4]['aired'] %}{{ text.split('-')[0].strip()}}" 

  - platform: template
    sensors:
      plex_recently_movies_play_movie_4:
        friendly_name: "Movie 4 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_4')}}", "year": "{{states('sensor.plex_recently_movies_year_4') }}" }
        
  - platform: template
    sensors:
      plex_recently_movies_name_5:
        friendly_name: "Movie 5 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[5]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_5:
        friendly_name: "Movie 5 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[5]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_5:
        friendly_name: "Movie 5 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[5]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_5:
        friendly_name: "Movie 5 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[5]['flag'] }}"
        

  - platform: template
    sensors:
      plex_recently_movies_name_6:
        friendly_name: "Movie 6 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[6]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_6:
        friendly_name: "Movie 7 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[6]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_6:
        friendly_name: "Movie 6 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[6]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_6:
        friendly_name: "Movie 6 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[6]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_6:
        friendly_name: "Movie 6 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[6]['aired'] %}{{ text.split('-')[0].strip()}}" 
        
  - platform: template
    sensors:
      plex_recently_movies_play_movie_6:
        friendly_name: "Movie 6 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_6')}}", "year": "{{states('sensor.plex_recently_movies_year_6') }}" }        

  - platform: template
    sensors:
      plex_recently_movies_name_7:
        friendly_name: "Movie 7 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[7]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_7:
        friendly_name: "Movie 7 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[7]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_7:
        friendly_name: "Movie 7 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[7]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_7:
        friendly_name: "Movie 7 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[7]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_7:
        friendly_name: "Movie 7 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[7]['aired'] %}{{ text.split('-')[0].strip()}}" 

  - platform: template
    sensors:
      plex_recently_movies_play_movie_7:
        friendly_name: "Movie 7 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_7')}}", "year": "{{states('sensor.plex_recently_movies_year_7') }}" }

  - platform: template
    sensors:
      plex_recently_movies_name_8:
        friendly_name: "Movie 8 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[8]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_8:
        friendly_name: "Movie 8 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[8]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_8:
        friendly_name: "Movie 8 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[8]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_8:
        friendly_name: "Movie 8 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[8]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_8:
        friendly_name: "Movie 8 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[8]['aired'] %}{{ text.split('-')[0].strip()}}" 

  - platform: template
    sensors:
      plex_recently_movies_play_movie_8:
        friendly_name: "Movie 8 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_8')}}", "year": "{{states('sensor.plex_recently_movies_year_8') }}" }

  - platform: template
    sensors:
      plex_recently_movies_name_9:
        friendly_name: "Movie 9 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[9]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_9:
        friendly_name: "Movie 9 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[9]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_9:
        friendly_name: "Movie 9 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[9]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_9:
        friendly_name: "Movie 9 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[9]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_9:
        friendly_name: "Movie 9 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[9]['aired'] %}{{ text.split('-')[0].strip()}}" 

  - platform: template
    sensors:
      plex_recently_movies_play_movie_9:
        friendly_name: "Movie 9 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_9')}}", "year": "{{states('sensor.plex_recently_movies_year_9') }}" }

  - platform: template
    sensors:
      plex_recently_movies_name_10:
        friendly_name: "Movie 10 name"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[10]['title'] }}"

  - platform: template
    sensors:
      plex_recently_movies_poster_10:
        friendly_name: "Movie 10 poster"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[10]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_movies_fanart_10:
        friendly_name: "Movie 10 fanart"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[10]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_movies_flag_10:
        friendly_name: "Movie 10 play status"
        icon_template: mdi:movie-roll
        value_template: "{{ state_attr('sensor.recently_added_movies', 'data')[10]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_movies_year_10:
        friendly_name: "Movie 10 Year"
        icon_template: mdi:movie-roll
        value_template: "{% set text = state_attr('sensor.recently_added_movies', 'data')[10]['aired'] %}{{ text.split('-')[0].strip()}}" 

  - platform: template
    sensors:
      plex_recently_movies_play_movie_10:
        friendly_name: "Movie 10 play button"
        icon_template: mdi:movie-roll
        value_template: >-
         { "library_name": "Movies", "title": "{{states('sensor.plex_recently_movies_name_10')}}", "year": "{{states('sensor.plex_recently_movies_year_10') }}" }


############# TV Shows Plex ###############
### 1 ###
  - platform: template
    sensors:
      plex_recently_tvshow_title_1:
        friendly_name: "tv show episode name"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[1]['episode'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_poster_1:
        friendly_name: "tv show 1 poster"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[1]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_fanart_1:
        friendly_name: "tv show 1 fanart"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[1]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_flag_1:
        friendly_name: "tv show 1 play status"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[1]['flag'] }}"


  - platform: template
    sensors:
      plex_recently_tvshow_play_tvshow_1:
        friendly_name: "tv show 1 play button"
        icon_template: mdi:television-classic
        value_template: >-
         { "library_name": "TV_Shows", "show_name": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[1]['title'] }}", "season_number": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[1]['number'].split('E')[-2] | replace('S',' ') }}", "episode_number": "{{state_attr('sensor.recently_added_tv_shows', 'data')[1]['number'].split('E')[1] }}" }

### 2 ###
  - platform: template
    sensors:
      plex_recently_tvshow_title_2:
        friendly_name: "tv show 2 episode name"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[2]['episode'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_poster_2:
        friendly_name: "tv show 2 poster"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[2]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_fanart_2:
        friendly_name: "tv show 2 fanart"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[2]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_flag_2:
        friendly_name: "tv show 2 play status"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[2]['flag'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_play_tvshow_2:
        friendly_name: "tv show 2 play button"
        icon_template: mdi:television-classic
        value_template: >-
         { "library_name": "TV_Shows", "show_name": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[2]['title'] }}", "season_number": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[2]['number'].split('E')[-2] | replace('S',' ') }}", "episode_number": "{{state_attr('sensor.recently_added_tv_shows', 'data')[2]['number'].split('E')[1] }}" }

### 3 ###
  - platform: template
    sensors:
      plex_recently_tvshow_title_3:
        friendly_name: "tv show 3 episode name"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[3]['episode'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_poster_3:
        friendly_name: "tv show 3 poster"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[3]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_fanart_3:
        friendly_name: "tv show 3 fanart"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[3]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_flag_3:
        friendly_name: "tv show 3 play status"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[3]['flag'] }}"


  - platform: template
    sensors:
      plex_recently_tvshow_play_tvshow_3:
        friendly_name: "tv show 3 play button"
        icon_template: mdi:television-classic
        value_template: >-
         { "library_name": "TV_Shows", "show_name": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[3]['title'] }}", "season_number": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[3]['number'].split('E')[-2] | replace('S',' ') }}", "episode_number": "{{state_attr('sensor.recently_added_tv_shows', 'data')[3]['number'].split('E')[1] }}" }

### 4 ###
  - platform: template
    sensors:
      plex_recently_tvshow_title_4:
        friendly_name: "tv show 4 episode name"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[4]['episode'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_poster_4:
        friendly_name: "tv show 4 poster"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[4]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_fanart_4:
        friendly_name: "tv show 4 fanart"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[4]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_flag_4:
        friendly_name: "tv show 4 play status"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[4]['flag'] }}"


  - platform: template
    sensors:
      plex_recently_tvshow_play_tvshow_4:
        friendly_name: "tv show 4 play button"
        icon_template: mdi:television-classic
        value_template: >-
         { "library_name": "TV_Shows", "show_name": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[4]['title'] }}", "season_number": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[4]['number'].split('E')[-2] | replace('S',' ') }}", "episode_number": "{{state_attr('sensor.recently_added_tv_shows', 'data')[4]['number'].split('E')[1] }}" }

### 5 ###
  - platform: template
    sensors:
      plex_recently_tvshow_title_5:
        friendly_name: "tv show 5 episode name"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[5]['episode'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_poster_5:
        friendly_name: "tv show 5 poster"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[5]['poster'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_fanart_5:
        friendly_name: "tv show 5 fanart"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[5]['fanart'] }}"

  - platform: template
    sensors:
      plex_recently_tvshow_flag_5:
        friendly_name: "tv show 5 play status"
        icon_template: mdi:television-classic
        value_template: "{{ state_attr('sensor.recently_added_tv_shows', 'data')[5]['flag'] }}"


  - platform: template
    sensors:
      plex_recently_tvshow_play_tvshow_5:
        friendly_name: "tv show 5 play button"
        icon_template: mdi:television-classic
        value_template: >-
         { "library_name": "TV_Shows", "show_name": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[5]['title'] }}", "season_number": "{{ state_attr('sensor.recently_added_tv_shows', 'data')[5]['number'].split('E')[-2] | replace('S',' ') }}", "episode_number": "{{state_attr('sensor.recently_added_tv_shows', 'data')[5]['number'].split('E')[1] }}" }


1 Like