JBassett / plex_webhooks

Plex Webhook support for Home Assistant
18 stars 8 forks source link

No events being sent from plex to home assistant #2

Closed HumanSkunk closed 3 years ago

HumanSkunk commented 3 years ago

I found your project when trying to find a webhooks solution for plex using Home Assistant.

I have set everything up following your readme, created a folder within the configuration settings and downloaded the files. I have set up a webhook request within plex to the pi running homebridge and everything has successfully restarted. I have used plex_webhook as the ID in the configuration.yaml file.

However i see no devices or entities added from the creation of the code. I may have misconfigured something or misunderstood how this works.

HumanSkunk commented 3 years ago

So after looking through my plex logs the webhook request being sent is getting a 404 response. I have set my URL to http://{{ipofmypirunninghassio}}:8123/api/webhooks/plex_webhook. Navigating to this address gives me a 404 error. In the configuration.yaml i have an entry: plex_webhooks: webhook_id: plex_webhook And within the folder custom_components/plex_webhooks i have loaded the two files in from your repo

I have clearly missed something and i dont know what it is. Any help would be much appreciated.

HumanSkunk commented 3 years ago

Realised that there is a typo in the address set up in plex where it should be webhook and not webhooks. This no longer caused Plex to complain and it seems that they are now being sent. However there is no sign within HA they are being received. I tried to set up a simple automation that when a webhook trigger (plex_webhook) is received then turn off lights. But i see no evidence of anything being received by home assistant.

JBassett commented 3 years ago

Here is a sample automation I have that I know is working notice the event_type is PLEX_EVENT:

- id: 5a876f15-8e89-4933-9b0f-f40c45881a36
  alias: 'Plex - Movie Downloaded'
  initial_state: 'on'
  trigger:
    - platform: event
      event_type: PLEX_EVENT
      event_data:
        status: GRABBED
        type: movie
  condition:
    - condition: time
      after: '07:00:00'
      before: '23:00:00'
    # Make sure we aren't already watching something on the home
    - condition: state
      entity_id: media_player.kitchen_display
      state: 'off'
  action:
  - service: tts.google_translate_say
    entity_id: media_player.kitchen_display
    data:
      cache: false
      message: "Get the popcorn ready, I just downloaded {{ trigger.event.data['Metadata']['title'] }}."
HumanSkunk commented 3 years ago

Yes I managed to fix it. The issue was I didnt have the right playerUUID entered. I thought it was the name of the device that was added to the Plex server when it links, but it is a much longer random string which I extracted from the Plex log files. Works a treat. The standard plugin would constantly poll the Plex server (which I have sleeping to save energy when it isn't in use), so constantly woke it up. This method pushes its statues and is much cleaner for a not always on Plex server.