Plex webhook trigger help

I am testing the new webhook trigger in 0.80 and have managed to set up an automation to send a notification to see what a Plex webhook looks like…

- alias: 'plex_webhook_test'
  initial_state: 'True'
  trigger:
    - platform: webhook
      webhook_id: plex_webhook_test
  action:
    - service: notify.hass
      data_template:
        message: >
          {{ trigger.data }}
        title: "Plex Webhook Test"

This successfully sends the following notification on each play/pause/stop/resume…

<MultiDictProxy(‘payload’: bytearray(b’{“event”:“media.resume”,“user”:true,“owner”:true,“Account”:{“id”:1,“thumb”:“https://plex.tv/users/REDACTED/avatar?c=1538338798",“title”:“REDACTED”},“Server”:{“title”:“NAS”,“uuid”:“REDACTED”},“Player”:{“local”:true,“publicAddress”:"",“title”:“Chrome”,“uuid”:“REDACTED”},“Metadata”:{“librarySectionType”:“show”,“ratingKey”:“248”,“key”:"/library/metadata/248",“parentRatingKey”:“237”,“grandparentRatingKey”:“236”,“guid”:“com.plexapp.agents.thetvdb://72668/1/11?lang=en”,“librarySectionTitle”:" Kids TV”,“librarySectionID”:1,“librarySectionKey”:"/library/sections/1",“type”:“episode”,“title”:“The Black Island (2)”,“titleSort”:“Black Island (2)”,“grandparentKey”:"/library/metadata/236",“parentKey”:"/library/metadata/237",“grandparentTitle”:“The Adventures of Tintin”,“parentTitle”:“Season 1”,“contentRating”:“TV-G”,“summary”:"Tintin follows M\xc3\x83\xc2\xbcller and Ivan to Kiltoch.\r\nIn Kiltoch he gets to know about Blac

Anyone know how to use this data to create meaningful Plex automations? (So far all my attempts at templates have failed with various error messages)

Cheers,
James

Did you find any solutions ? as webhooks seems the easier and faster solution but not easy to decode the string received :frowning:

2 Likes

I got as far as

trigger.data.payload.decode()

which gives me a long string with all the data in it. Can’t figure out how to get the string to a dict so I can pull out what I want

After combining some information on different topics I got it all working.
Only problem is most of the times it won’t fire from the first play. So I have to pause and play again to get it firing. But it is working

link to configuration