Jellyfin Playback Notification

To help emulate the Tautulli playback notifications i have setup the following on my Jellyfin server and HA to send me a notification when someone starts playing a movie or show.

Jellyfin Generic Webhook on Playback event, URL is the URL of your HA Webhook:

{
    "Name": "{{{Name}}}",
    "Username": "{{{Username}}}",
    "NotificationUsername": "{{NotificationUsername}}",
    "SeriesName": "{{SeriesName}}",
    "SeasonNumber00": "{{SeasonNumber00}}",
    "EpisodeNumber00": "{{EpisodeNumber00}}",
    "Year": "{{Year}}",
    "ServerName": "{{ServerName}}",
    "NotificationType": "{{NotificationType}}",
    "DeviceName": "{{DeviceName}}",
    "ClientName": "{{ClientName}}",
    "ItemType": "{{ItemType}}",
    "ItemId": "{{ItemId}}",
    "ServerUrl": "{{ServerUrl}}",
    "ServerId": "{{ServerId}}",
    "Thumbnail": "https://URLOFSERVER/Items/{{ItemId}}/Images/Primary",
    "ItemUrl": "https://URLOFSERVER/web/index.html#!/details?id={{ItemId}}&serverId={{ServerId}}",
    "Provider_tmdb": "{{Provider_tmdb}}",
    "Provider_imdb": "{{Provider_imdb}}"
}

I have to hardcode my Jellyfin URL as the serverUrl variable doesnt work for me - not sure why.

Here is my automation YAML

alias: Jellyfin Webhook Notification
description: ''
trigger:
  - platform: webhook
    webhook_id: YOURCUSTOMWEBHOOKID
condition: []
action:
  - service: notify.mobile_app_iphone
    data:
      title: '{{ trigger.json.ServerName }}: {{ trigger.json.NotificationType }}'
      message: >-
        {{ trigger.json.NotificationUsername | capitalize }} started playing
        from {{ trigger.json.ClientName }} on {{ trigger.json.DeviceName }}
      data:
        subtitle: >-
          {% if trigger.json.ItemType == 'Episode' %} {{ trigger.json.SeriesName
          }} - S{{ trigger.json.SeasonNumber00 }}E{{
          trigger.json.EpisodeNumber00 }} - {{ trigger.json.Name }} {% else %}
          {{ trigger.json.Name }} ({{ trigger.json.Year }}) {% endif %}
        image: '{{ trigger.json.Thumbnail }}'
        group: jellyfin-notification-group
        url: '{{ trigger.json.ItemUrl }}'
        actions:
          - action: URI
            title: View on IMDB
            uri: https://www.imdb.com/title/{{ trigger.json.Provider_imdb }}
mode: single

Here is the notification, opening it will show you a cover or thumbnail from the show and provide a link to IMDB. Tapping the notification opens up the jellyfin server to the item being played.

So although this all works i was wondering if there was a better way of doing this or how else this could be expanded upon?

There doesnt appear to be a good way to make the actions contextual, i.e. if TV show show these actions else show these.

7 Likes

Nice job! Can you help me for configure that notifications?
I don’t know where i should put the webhook template for notification.
Thanks in advance!

You need to setup this first - Automation Trigger - Home Assistant

Then make sure you have the webhook plugin installed in jellyfin, add a new generic webhook pointing at your URL.

All it’s done :grinning:
But how i need configure the Webhook plugin for Jellyfin?
This plugin don’t have any configuration in UI.

Yes it does. Go to admin > plug-ins > we hook

Add Generic Webhook and complete the form.


I think it’s work, but in Home Assistant i get this error:

I’m using just the generic one. Not the form one.

this is great can you share how to do it… what is URL of HA Webhook
My ha server is http://192.168.0.180:8123
what should i add in server url?

@eximo84 what should i add here in webhook destination url?

In HA. Create a new automation with the webhook trigger. You will be given a url. Use this URL in Jellyfin.

@eximo84 thanks it works… But is their any way to listen to the webhook event and see what data did we actually receive? I want to try some automations based on the values I get

Yes you can use a service on line to consume webhooks and then see the json. Also the webhook plugin has all the details.

I have since set a webhook sensor that populates when playing passing over movie info etc so I can trigger automations to lights.

1 Like

what is this…is this under jellyfin or ha… so far i tried to use debug in nodered to read all the values. and made a sensor and attributes to make automation something similar and also i use webscarping to get the user reports to my dashboard to show up in graph, to see how much time am i spending each day.
i alredy have rescue time setup soo if i start to watch movie or series in my prodcutive hours i get notifictaion to make sure i just stop using it ,also im able to send android notification which kills the app instantly or open my productive app.
thanks again

A tool like postman where you send the json data to so you can read it.

Trying to set this up but get:

Error rendering data template: UndefinedError: 'dict object' has no attribute 'json'

Using the templates above. Generic webhook option. ;/

According to the HA documentation, to send payload data it is necessary to specify the Content-Type header with the value application/json. You can do this by setting a new Request Header in Webhook plugin Jellyfin:

1 Like

Thanks very much for sharing this! Was able to get it up and running in about 10 minutes or so thanks to your shared config and the Q&A in this thread. Quite a nice automation :smiley:

There’s a custom component now, I think there’s notifications in that

1 Like

Thank you so much for this config!
I always wanted to send notifications to my TV and phone when new content was added, with some minor adjustments based on your config it now works like a charm!

1 Like

That information is gold, thanks so much for sharing!

I’ve just been looking for a way to trigger a notification test in jellyfin, guess there isn’t one yet. But thanks again for the work you did!