Have updated the blueprint, cleaned up the UI and grouped Actions for Movie, TV, Music.
Now options to set actions for Media when it is Rated, New Content Added, Server Owner Actions (Database backup complete or Database corruption detected).
Adjust the Automation to run in Single, Restart, Queued or Parallel mode. Increase/Decrease the trace count.
Struggling to get the Plex Client Name? Not a problem, as long as the webhook has been setup properly on Plex Server to send to Home Assistant. Enable the Plex Client Name? option and Home Assistant notification will be presented (when a Plex webhook is triggered) that will present the client name.
Does the webhook give surround audio details at all (e.g. 2.0, 5.1, 7.1 etc) as this would be damn useful for my current challenge (changing the AVR’s sound mode depending on the media’s surround type)
Thanks for this blueprint, super handy! However I’ve run into an annoying issue. I have two Apple Tv’s in my house and even though each Apple TV is named (in Apple TV settings), in the Plex web hook data it calls the player “Apple TV” for both units. However under the “Player” details in the webhook payload, there is a uuid that seems to be unique. Might try modifying this blueprint to read the uuid instead of player name.
I have updated the blueprint, you can use client uuid or name (just for anyone who updates who is already using it), the uuid takes precedence over the name.
the option to retrieve the client name also gives the uuid as well now.
I want to thank you for this blueprint! I wanted to use n8n, but could not get the Plex communicate with n8n add-on, your way is far better and easier
if someone is interested, here is my example of notification if Play is started and when new media is added to the Library.
alias: Plex Webhook Handler RELEASE (v0.4.4)
description: ""
use_blueprint:
path: thenextbutton/plex_webhook_release.yaml
input:
# This is your unique Home Assistant Webhook ID. You can find it in your Plex Media Server's webhook configuration.
webhook_id: YOUR_HOME_ASSISTANT_WEBHOOK_ID_HERE # Example: 8f4e2c1a-b05d-4f67-8e90-1234567890ab
plex_client_uuid:
# These are the UUIDs for your Plex Libraries (e.g., Movies, TV Shows)
# You can find a library's UUID by viewing media in that library in Plex and checking its XML.
- YOUR_PLEX_LIBRARY_UUID_1 # Example: 9c0b1d2e-f34g-5h6i-7j8k-l9m0n1o2p3q4
- YOUR_PLEX_LIBRARY_UUID_2 # Example: a7b8c9d0-e1f2-g3h4-i5j6-k7l8m9n0o1p2
# These are the UUIDs for your Plex Playing Devices (e.g., Apple TV, Smart TV, Mobile Phone)
# Find these in the Home Assistant automation trace data when the device plays media.
- YOUR_PLEX_PLAYER_UUID_1 # Example: F5E4D3C2-B1A0-9E8D-7C6B-5A4B3C2D1E0F
- YOUR_PLEX_PLAYER_UUID_2 # Example: p9q8r7s6t5u4v3w2x1y0z9a8b7c6d5e4
# Add more device UUIDs as needed for any other players you want to trigger notifications.
plex_client: [] # Leave this empty to rely solely on player UUIDs for client filtering (recommended).
movie_resume_mimics_play: true
movie_play_actions:
# Replace 'notify.mobile_app_your_device_name' with your specific mobile app notification service name.
# You can find this under Developer Tools -> Services in Home Assistant.
- service: notify.mobile_app_main_phone # Example: notify.mobile_app_living_room_tablet
data:
# Message with bold movie title. Customize player_title if needed (e.g., rename "TV 2022" to "Samsung TV").
message: "🎬 Movie '<b>{{ payload.Metadata.title }}</b>' started on {{ player_title }}!"
title: "Plex Playback"
data: # This 'data' block is for mobile_app specific features.
html: true # Enable HTML rendering for the message.
# Replace 'http://YOUR_PLEX_IP:YOUR_PLEX_PORT' with your Plex Media Server's actual IP address and Port.
# Replace 'YOUR_PLEX_TOKEN_HERE' with your actual X-Plex-Token.
image: "http://192.168.1.50:32400{{ payload.Metadata.thumb }}?X-Plex-Token=RANDOM_TOKEN_XYZ123ABC" # Example: http://10.0.0.200:32400
notification_icon: "mdi:movie"
# Replace '/your-dashboard-path' with the actual path to your desired Home Assistant dashboard (e.g., /lovelace/main, /a_custom_dashboard).
clickAction: /media-info/plex # Example: /home/overview
episode_play_actions:
- service: notify.mobile_app_main_phone # Example: notify.mobile_app_bedroom_tv
data:
# Message with bold episode and show title. Customize player_title if needed.
message: "🎬 Episode '<b>{{ payload.Metadata.title }}</b>' from '<b>{{ payload.Metadata.grandparentTitle }}</b>' started on {{ player_title }}!"
title: "Plex Playback"
data:
html: true
# Replace 'http://YOUR_PLEX_IP:YOUR_PLEX_PORT' and 'YOUR_PLEX_TOKEN_HERE'.
# For TV show episodes, 'grandparentThumb' is typically the show's poster.
image: "http://192.168.1.50:32400{{ payload.Metadata.grandparentThumb }}?X-Plex-Token=ANOTHER_RANDOM_TOKEN_DEF456GHI"
notification_icon: "mdi:television-play"
clickAction: /media-info/plex # Example: /automation/logs
library_new_movie:
- service: notify.mobile_app_main_phone # Example: notify.mobile_app_home_hub
data:
message: "New Movie Added: <b>{{ payload.Metadata.title }}</b> 🎬"
title: "Plex Library Update"
data:
html: true
# Replace 'http://YOUR_PLEX_IP:YOUR_PLEX_PORT' and 'YOUR_PLEX_TOKEN_HERE'.
image: "http://192.168.1.50:32400{{ payload.Metadata.thumb }}?X-Plex-Token=YET_ANOTHER_TOKEN_JKL789MNO"
notification_icon: "mdi:filmstrip-new"
clickAction: /media-info/plex # Example: /lovelace/library_overview
library_new_tv_show:
- service: notify.mobile_app_main_phone # Example: notify.mobile_app_guest_tablet
data:
message: "New TV Show Episode Added: <b>{{ payload.Metadata.title }}</b> from <b>{{ payload.Metadata.grandparentTitle }}</b> 🎬"
title: "Plex Library Update"
data:
html: true
# Replace 'http://YOUR_PLEX_IP:YOUR_PLEX_PORT' and 'YOUR_PLEX_TOKEN_HERE'.
# For new TV show episodes, 'grandparentThumb' is typically the show's poster.
image: "http://192.168.1.50:32400{{ payload.Metadata.grandparentThumb }}?X-Plex-Token=FINAL_RANDOM_TOKEN_PQR012STU"
notification_icon: "mdi:new-box"
clickAction: /media-info/plex # Example: /tv-shows/new_releases
What are you trying to get the Server Owner Actions to do?
If Webhooks are triggering Ok, then try Admin Playback Started.
The default code I put there as an example should be:
metadata: {}
data:
title: "{{ payload.Account.title }} - Playback started"
notification_id: plex_user_playback_{{ payload.Account.title }}
message: " {{ payload.Account.title }} has started {% if payload.Metadata.type == 'album' %} listening to the album {{ payload.Metadata.title }} by {{ payload.Metadata.parentTitle }} {% elif payload.Metadata.type == 'movie' %} to watch the movie {{ payload.Metadata.title }} {% elif payload.Metadata.type == 'episode' %} to watch the TV show {{ payload.Metadata.grandparentTitle }} {% else %} interacting with Plex Media Server {{ payload.Server.title }} {% endif %} on the device {{ payload.Player.title }}"
action: persistent_notification.create
and when you switch to another user within your plex environment and start playback you should see something along the lines of this within your home assistant notifications:
This is excellent! I love it.
I’ve got Plex triggering lighting controls and updates on the MAX7219 display…
Now, I need to find someone to 3d print a nice enclosure for the display …
corrected the server owner actions for Admin Playback trigger, it was only capturing audio playback, have fixed to media.play from playback.started and it is capturing movies, episodes and movies events. (that was a bad idea, reverted that. Apologies.)
Have also updated the default message for this event as well.
Try using the Generic Playback actions, and under that the playback started option. This is triggered before the player specific actions.
I copied this code, from the Admin Playback Started example in the blueprint to the Generic section (
The Admin Playback Started shows all users minus the main Plex account). I can see notifications appearing :
metadata: {}
data:
title: "{{ payload.Account.title }} - Playback started"
notification_id: plex_user_playback_{{ payload.Account.title }}
message: >-
{{ payload.Account.title }} has started {% if payload.Metadata.type ==
'track' %}listening to {{ payload.Metadata.title}} by {% if
payload.Metadata.originalTitle is defined and
payload.Metadata.originalTitle|length > 0 %} {{
payload.Metadata.originalTitle }} {% else %} {{
payload.Metadata.grandparentTitle }} {% endif %} from the album {{
payload.Metadata.parentTitle }}{% elif payload.Metadata.type == 'movie' %}to
watch the movie {{ payload.Metadata.title }} ({{ payload.Metadata.year }})
directed by {{ payload.Metadata.Director[0].tag }}{% elif
payload.Metadata.type == 'episode' %}to watch the TV show {{
payload.Metadata.grandparentTitle }} Season {{ payload.Metadata.parentIndex
}} Episode {{ payload.Metadata.index }} ({{ payload.Metadata.title }}){%
elif payload.Metadata.type == 'album' %}listening to the album {{
payload.Metadata.title }} by {{ payload.Metadata.parentTitle }}{% else %}
interacting with Plex Media Server {{ payload.Server.title }}{% endif %}{%
if payload.Player.title|length > 0 %} on the device {{ payload.Player.title
}}{% endif %}
action: persistent_notification.create