Hi!
I have a pretty simple question: Is it in any way possible to put data into the response of a webhook. For example a sensor might call a webhook and the sensor wants to know the time, so my idea was to return the time in the response. How or is that even possible?
Thanks!
What time ?
Current time ? You can use now()
(or now().isoformat()
) in the request or in the response.
Time of request ? You can pass a parameter in the request and retrieve it using trigger.query
I know that I can use now() but I want to know how to put that into the response.
Share your current approach with us.
Everything from the response of an automation webhook is here:
We might be talking about different things.
It helps if you share what you already have in the code.
So I basically have nothing so far, but I’m Sorry if I wasn’t clear. I mean the http response. So the sensor calls the webhook with some json data, the webhook processes and responds with the time. So that the sensor can display it.
Have you had any luck with this? This is exactly what I need as well. I have an automation setup but I need to return certain data when the webhook is called.
Update: I was able to accomplish this by creating a simple app in java that handles the webhook/response and acts as a middleman with HomeAssistant. The idea is the middleman program will be getting/setting values in home assistant, and when the webhook is called, the middleman program generates the response and sends it to the caller. However, I would not recommend this unless you know what you’re doing as it requires opening up another port outside of home assistant, and if your program isn’t properly secured can lead to attacks against your home assistant.
I am having the same issue, need the webhook to return something, even if its just OK. null is causing me an issue. Anyone ever got this to happen? Thanks