#Can't get webhooks to work -- curl report errors

1 messages · Page 1 of 1 (latest)

edgy cipher
#

I am trying to trigger an automation from a webhook call from my internal network

  triggers:
    - trigger: webhook
      webhook_id: "webhook_id"
      variables:
        phase: "{{'on' if trigger.data.phase == 'start' else 'off'}}"

However, when I try to call this, curl reports an error. From Windows I have

curl -X POST -H "Content-Type: application/json" -d '{ "phase": "start"}' https://[myha.lan]:8123/api/webhook_id
curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - The token supplied to the function is invalid

From my TrueNAS (Linux) where I actually want it to work

curl -X POST -H "Content-Type: application/json" -d '{ "phase": "start"}' https://[myha.lan]:8123/api/webhook/webhook_id
curl: (35) OpenSSL/3.0.13: error:0A00010B:SSL routines::wrong version number

Maybe this is because there is no https? (I am running a bare-metal HAOS installation). But If I replace https with http, then there is no error, but also no effect. If indeed its an https issue -- what do I need to do to make this work internally (I have an HA Clooud subscription is that is necessary, but I would like to keep this internal)

spice talon
#

If you visit https://[myha.lan]:8123/ in a browser what happens?

edgy cipher
#

I get an error that the site can’t provide a secure connection.

NSURLErrorSecureConnectionFailed

spice talon
#

Then clearly the curl won't work 😉

#

What if you just do http://?

#

I'm guessing that'll work

edgy cipher
#

then there is no respose

#

I mean -- no error but HA doesn't seem to see it either

spice talon
#

But in the browser?

edgy cipher
#

that's my normal Ha dashboard which works fine

spice talon
#

Then that's the right URL for the curl command

edgy cipher
#

so webhooks can in principle work over http?

spice talon
#

Not just in principle, they do work over HTTP, or HTTPS, or whatever your HA is set to support

#

I use webhooks locally, with plain http

edgy cipher
#

Is there some way to see what HA is receiving?

spice talon
#

Now, I've never seen anybody embed variables in the trigger before - where did you get that from?

#
  triggers:
    - trigger: webhook
      webhook_id: "webhook_id"
      variables:
        ^^^^^ this bit
edgy cipher
#

oh I do that all the time for normal state triggers, but I've never tried a webhook before

spice talon
#

I assume then it must work, just not something I've seen (but then new features turn up every month...)

#

You've checked the automation trace?

edgy cipher
#

it was not triggering. But I hav ejust removed and now it work... So apparently it was the variables statement.

I use it to combine multiple triggers into one automation, but apparently it is nt supported with webhooks

#

ok thank you. now it work

neon horizon
#

hi i am wondering how to go about using parameters within a webhook and starting a different automation or calling a service or whatever. I am trying to add some visual feedback to my yealink t48s voip phone and i can call the webhook but i think it is crazy to add different webhooks for the same device when only a parameter is different. Any insights?

#

For the record, i have a webhook configured to use GET requests and the idea is like this: ha.local:8123/api/webhook/yealink?a=offhook or ../yealink&a=ringing

spice talon