Do something on said request (this is can be accomplished with webhooks)
Return a CUSTOM response (the state of a sensor following the automation for example)
Do something with said response in my other device
From what I gathered from the docs and countless hours of searching, it is not possible to create a custom reponse for webhooks to pass an arbitrary payload back to the caller.
I think I get you now…Just to confirm, you want the http response to the websocket request to contain some custom info in the body , ie more than a 200 ok in the header?
Did anyone of you guys mange to find a solution to this?
I want to do this:
Request: GET /webhooks/{id}
Response: 200 OK with data {“whateverIwant”: “whateverValue”}
It is possible to do a custom response for a webhook with Google Apps Script for example. But i cant find a way to do this in Home Assistant or Node Red in Home Assistant…
I need to do the same thing. I have a service that post’s a validation token (a string) to the webhook that needs to be sent back in an HTTP 200 response within 10 seconds. I was hoping this was something I could use with Nabu Casa, but I see no way to process the incoming JSON payload and then responding with my own JSON.
I am also wanting to do this. I want to expose an webhook URL that will just response true or false but I also can not find any way to do it with node red and the webhook node.
It would be nice to have such a functionality without the overhead of using node red just to provide custom body data and a custom endpoint name.
The idea is to create or simulate a customizable Api endoint on the HA server, that can be used locally to provide customizable json payload to the caller.
Not sure why you want webhook to send the response body, this is not a standard.
You can just call a home assistant API and get the state data - the call via the API is also secure - specifically /api/states/<entity_id>. So if you want some custom data, here would be the steps:
When you make a webhook call, your automation could update some data in particular entity of which you want your data as response
After you get the 200 status from webhook, your client application can again make a API call for that entity. This would also be more performance since your client is not tied to sync call of webhook REST API | Home Assistant Developer Docs