Cannot get webhook to work

I cannot get the webhook event to register … I have tried listening to * and nothing logs when I Post data to:
https://MyDomain.com/api/webhook/MySecret
… the domain works … I get a 405 when I use a GET but 200 when I POST, but nothing triggers
I have thins in my config:

automation:
  trigger:
    platform: webhook
    webhook_id: MySecret

Any ideas?
Thanks,
Kris

1 Like

CAn you check your home-assistant.log file to see if anything is being triggered? You definitely have to POST, but it seems like you’re doing everything right.

Do you have any conditions or actions in this automation? If your conditions are not met, or you don’t have any actions, the trigger may not fire.

I have no automation for this yet, but shouldn’t need one to test through the developer event section…
For example if you listen to asd and then send the event asd, HA will pick up the event.

I think this is just a limitation of the developer section. Until an actual trigger is registered for the webhook, it won’t fire. I use lots of webhooks and I just tried this myself.

No matter what webhook ID I use, I get this in my home-assistant.log file:

WARNING (MainThread) [homeassistant.components.webhook] Received message for unregistered webhook asdf

Ok you are right registering an automation for the webhook made it fire…
How do i pick up the event data that I passed in in the POST method?

{ "action": "raiseevent", "event": "test" }

Thanks again,
Kris

You can use any of these in your condition or action templates:

So, in your case:

{{ trigger.json.action }}

Still some trouble…
I have the following:

- id: '1111111111111'
  alias: Webhook Fire Event
  description: ''
  trigger:
  - platform: webhook
    webhook_id: MySecret
  condition:
  - condition: template
    value_template: '{{ trigger.json.action == "raiseevent" }}'
  action:
  - event: '{{ trigger.json.event }}'
    event_data: {}

… but I want the event that is fired to be the one specified in the trigger.json.event … this is not happening…

Edit: I should prob state that the documentation at https://www.home-assistant.io/docs/automation/templating/ doesn’t mention anything about templating the event stuff only data_template & service_template …
I seriously wish you could just use {{}} anywhere (don’t know why it wasn’t done this way) :stuck_out_tongue:

Any more ideas?
Thanks,
Kris

You could always just hardcode the event is and make one of the data attributes the one you filter on in automation triggers.

service:
  - event: hardcoded_event_id
    event_data_template:
      custom_attribute: '{{ trigger.json.event }}'
automation:
  trigger:
    - platform: event
      event_type: hardcoded_event_id
      event_data:
        custom_attribute: "whatevs"

I have never tried this, but see if “event_template” works.

Thanks for reminding me about that. I’ve spent several hours beating my head against the wall. I could that the http request is coming in and getting a response, but nothing is getting logged or triggered. I had not registered a trigger!