Plex Sensor Notifications

Hi all,
I’m currently using the plex sensor to notify when playback begins in plex however it’s not as detailed as I’d like it to be.

Currently I have it printing the username and the title of the media being watched. This is all well and good except for a tv show it only shows the episode title if a TV show is being watched.

Ideally what I’d like is for it to show series title - SxxExx episode name.

I know they plex sensor doesn’t grab that information but is there a way to leverage the media_player attributes instead? Just not sure how it’d be done dynamically is all.

Here’s my current code.

- id: plexspy_notification
  alias: "Plex Spy notification"
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: sensor.plexspy
  action:
    - service: notify.html5
      data_template:
        message: >
          {%- if states.sensor.plexspy.attributes -%}
            {% set space = joiner(' ') %}
            {%- for attr in states.sensor.plexspy.attributes -%}
             {%- if not attr=="friendly_name" and not attr=="unit_of_measurement" -%}
              {{space()}}{{attr}} is watching {{states.sensor.plexspy.attributes[attr]}}.
             {%- endif -%}
            {%- endfor -%}
          {%- endif -%}
        title: "Plex {{ trigger.to_state.state }} people streaming. "
        target: 'William'

Any assistance would be amazing.
I’m basically trying to get rid of PlexPy in my environment.

1 Like