zachowj / hass-node-red

Companion Component for node-red-contrib-home-assistant-websocket to help integrate Node-RED with Home Assistant Core
MIT License
460 stars 182 forks source link

Unable to get webhooks working #75

Closed MikeGuest closed 3 years ago

MikeGuest commented 3 years ago

Hi.

I have node red installed using the HA integration, and I have installed custom integration from HACS. I have to admit at this point I'm fairly new to all of this, and it's highly likely something i've misunderstood.

I'm using duckdns rather than nabucasa - and i'm wondering if this is part of the cause? The webhook simply doesn't trigger (no response from the debug node) when i run the following:

curl -X POST https://mydomain.duckdns.org:8123/api/webhook/Test2

My flow is as follows

[{"id":"18c622f7.df314d","type":"ha-webhook","z":"ef83dd27.a19e28","name":"Incoming On Trigger 2","server":"2080cbf9.e73504","version":1,"outputs":1,"webhookId":"Test2","outputProperties":[{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"x":160,"y":100,"wires":[["d671282b.5d1c28","51a81786.11b908"]]},{"id":"3b777e10.6cfb8a","type":"comment","z":"ef83dd27.a19e28","name":"trying to make webhook work","info":"","x":170,"y":60,"wires":[]},{"id":"d671282b.5d1c28","type":"debug","z":"ef83dd27.a19e28","name":"Receive log","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":100,"wires":[]},{"id":"2080cbf9.e73504","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true}]

I keep getting the following errors in the HA log when i try to call the

Logger: homeassistant.components.webhook Source: components/webhook/init.py:84 Integration: Webhook (documentation, issues) First occurred: 22:42:10 (30 occurrences) Last logged: 22:49:56

Received message for unregistered webhook Test2 from 192.168.1.254

Hope you can help

zachowj commented 3 years ago

Running the latest version of this and the HA nodes?

When you deploy does the status text under the webhook node show Registered? Any errors in the NR logs when you deploy? You can also change the log level to debug for the nodered component to see if the webhook is being registered.

logger:
  logs:
    custom_components.nodered: debug

You can also try calling webhook/list to see if it has been registered.

[{"id":"368cb815.fefd08","type":"inject","z":"ffbd7f06.4a014","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":154,"y":1088,"wires":[["f9dad206.168f2"]]},{"id":"f9dad206.168f2","type":"ha-api","z":"ffbd7f06.4a014","name":"","server":"","version":1,"debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\": \"webhook/list\"}","dataType":"jsonata","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":290,"y":1088,"wires":[["ebeb8649.8f2c08"]]},{"id":"ebeb8649.8f2c08","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":454,"y":1088,"wires":[]}]
MikeGuest commented 3 years ago

Hi. Thanks for replying. Running latest version of this

node-red-contrib-home-assistant-websocket 0.33.1

When deployed, the status under the webhook node shows a white square on a green background and the text 'running'

Using the flow you sent me, I received 3 webhooks registered, but none of them are the one specified in the webhook node. (I have 2 automations and a smartthings integration which show successfully)

So it does look like the webhook is not registering.

Even with debug logging enabled and re-deploying the node, all I seem to get in the logs is

21 Jun 00:22:09 - [info] Stopping modified flows 21 Jun 00:22:09 - [info] Stopped modified flows 21 Jun 00:22:09 - [info] Starting modified flows 21 Jun 00:22:09 - [info] Started modified flows

Hope this makes sense. Thanks for the help so far Regards

zachowj commented 3 years ago

Is Node-RED showing up under integrations in HA? HA UI go to "Configuration" -> "Integrations"

Did you do step 4 in the install instructions when installed from HACS? https://github.com/zachowj/hass-node-red/blob/main/info.md#installation

MikeGuest commented 3 years ago

Bingo! You're a star.

I hadn't seen those instructions. The only ones i'd seen were at https://github.com/zachowj/hass-node-red in the readme.md where it's listed as step 8, but it just looks like part of the manual install instructions. Being a newbie, I missed it.

Thanks again for this.

(If I could make any suggestion at all, a link to the HACS install instructions from readme.md might avoid idiots like me pestering you for issues that aren't real issues :) )

Regards