Plex + Webhooks (WIP)

Anyone please?

This started bothering me so I wrote a simple custom component that will trigger an event for every webhook! It’s compatible with HACS, just need to add it as a custom repository.

If you guys have an issues right them up in github and I’ll do my best to fix!

1 Like

I opened a PR to Telegraf for supporting Plex Webhooks if anyone wants to try it out and give feedback: https://github.com/influxdata/telegraf/pull/6511

Hi thanks for sharing this. i have tried setting up but not sure how to see if it is working - how can i test it, and can you give some automation examples please?
cheers,
james

Here is an example from my config:

As you can see all you need to do is use the event platform for a trigger with the event_type of PLEX_EVENT. From there you can filter out the events you care about by using event_data. In my example I filter to only a single player, my living room TVs uuid.

Thanks will give that a go
Cheers

Hi,

Thank you JBasset! for sharing this ! Tonight I tried to implement it but unfortunately it doesn’t work. Plex can’t deliver the payload to Home Assistant. I think I’ve missed something but don’t know what.

For your information, I’m running home-assistant with docker-compose.

configuration.yaml

default_config:

tts:
  - platform: google_translate

switch:
  - platform: wake_on_lan
    name: Synok
    mac_address: "blablab"
    host: 192.168.1.5
    turn_off:
      service: shell_command.turn_off_synok

shell_command:
  turn_off_synok: "ssh [email protected] -o StrictHostKeyChecking=no 'sudo shutdown -h now'"

plex_webhooks:
  webhook_id: plex_webhook

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

home-assistant.log

2019-12-18 21:03:03 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for plex_webhooks which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

Plex Media Server.log

Dec 18, 2019 21:07:08.585 [0x7f474d6fb700] WARN - Webhook: Error delivering payload to http://192.168.1.2:8123/api/webhooks/plex_webhook: 404

http://192.168.1.2:8123 Is the base URL of Home Assistant running on my raspberry, works great. But when I go to http://192.168.1.2:8123/api/webhooks/plex_webhook :

Any idea ? Please let me know if you need more informations.

In case everyone doesn’t read all of the HA release notes in detail, the native Plex integration now uses websockets to update the sensor and media_players. This means instant updates instead of the old polling mechanism. If you were using webhooks for faster updates, give the native integration another shot.

2 Likes

Thank you jlaw, works like a charm :slight_smile:

I don’t think I need to use webhooks anymore.

1 Like

I just tried to get that working.
Also loaded the repo from @JBassett (https://github.com/JBassett/plex_webhooks) (thanks for the work) in my raspberry (HASS Host)

I stuck in step 9. Write automations, as most here in that thread :wink:

HASS UI – > Configuration --> Automations – > Add Automations --> New Automation --> Trigger

And now? Where do i have to copy which code to dim a light when Plex start playing?

Thank you

I’ve been using this method of getting the status of plex for quite some time and with the latest updates I am curious to what how the new MQTT trigger would be formatted. I would think it would be something like:

- trigger:
    mqtt:
        topic: "plex/update"

Anyone have any ideas or have gone through updating their configuration with the MQTT changes?

alias: Webhook From Plex
description: ""
trigger:
  - platform: webhook
    allowed_methods:
      - POST
    local_only: true
    webhook_id: "webhook_fingerprint"
condition:
  - condition: template
    value_template: "{{ (trigger.data.payload.decode() | from_json).event == 'library.new' }}"
action:
  - service: notify.persistent_notification
    data:
      message: |
        {{ (trigger.data.payload.decode() | from_json).event }}
         Új film a Plex-en: {{ (trigger.data.payload.decode() | from_json).Metadata.title }}
      title: Plex
  - service: script.nymnotify
    data:
      message: >
        Új film a Plex-en: {{ (trigger.data.payload.decode() |
        from_json).Metadata.title }}
mode: single