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

Webhooks not working with v0.5.0 #66

Closed katekyonni closed 3 years ago

katekyonni commented 3 years ago

Version of the custom_component

0.5.0

Describe the bug

After updating to v0.5.0 a few days ago all my webhooks stopped working. I now reverted to v0.4.5 an they started working again.

Maybe the cause is this change in v0.5.0: https://github.com/zachowj/hass-node-red/commit/a17ad73a975ba80082e6390d8520e06a0e99c952 Does the trailing comma after (request.rel_url.query) need to be removed?

Otherwise let me know how I can help to figure out the problem :)

zachowj commented 3 years ago

What version of HA and the HA palette in NR are you running?

I just tested v0.5.0 on HA version 2021.5.0 and NR palette v0.30.1 and everything seems to be working correctly.

You can try enabling the debug logs in HA for the custom component to see the registering and triggering of the webhooks in the HA logs.

in HA config

logger:
  logs:
    custom_components.nodered: debug

or via a service call

https://www.home-assistant.io/integrations/logger/#service-set_level

katekyonni commented 3 years ago

My Home Assistant version is 2021.4.6 and palette 0.30.1

I haven't enabled debug logging yet but I can see this in my logs every time I send a webhook:

2021-04-26 22:15:54 ERROR (MainThread) [homeassistant.components.webhook] Error processing webhook inoreader-deals
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 96, in async_handle_webhook
    response = await webhook["handler"](hass, webhook_id, request)
  File "/config/custom_components/nodered/websocket.py", line 167, in handle_webhook
    "params": dict(request.rel_url.query),
AttributeError: 'MockRequest' object has no attribute 'rel_url'

Edit: As soon as I revert back to v0.4.5 the error disappears and the webhook node receives the request as expected.

zachowj commented 3 years ago

Try v0.5.1 and see if that resolves the error above.

mjumnito commented 3 years ago

working for me, thanks

katekyonni commented 3 years ago

For me it's working now with 0.5.1 and I don't get any errors, so the problem I had seems to be solved. Thank you! 😄