Allow webhooks that support GET#19648
Allow webhooks that support GET#19648rohankapoorcom wants to merge 4 commits intohome-assistant:devfrom
Conversation
a6feb28 to
1c953e8
Compare
tests/components/test_webhook.py
Outdated
|
|
||
|
|
||
| async def test_getting_webhook_nonexisting(hass, mock_client): | ||
| """Test posting to a nonexisting webhook.""" |
tests/components/test_webhook.py
Outdated
|
|
||
|
|
||
| async def test_getting_webhook(hass, mock_client): | ||
| """Test posting a webhook with no data.""" |
|
Per definition is a webhook POST only. A Rest API support also GET but is not a webhook. |
|
While that is technically true, you miss two use cases:
The workaround would be to install a proxy server on the raspberry device which transforms get requests to post requests. But that seems pretty unnecessary... |
|
@andre2007 yeah that are RESTful calls and not webhooks calls. The question is now, do we want at a hack to webhook API to support RESTful API calls? We have already a RESTful interface on Home Assistant, but the webhook part feels a bit more integrated because you can easily use it in automation or with config flow. |
|
@pvizeli another option could be that we make another component (like webhook) that supports RESTful API calls (realistically only GET) to make it as integrated with automations and the config flow but that seems like a lot of duplicated code to maintain two separate components and confusion for users when to use which one. My opinion is that hacking it on top of the webhook component seems better integrated and cleaner in the longer term. |
|
If we create a RESTful version, we need to adopt the standards, and they allow more as only GET with becomes the URL also an important role. |
|
It seems a quite heavy artificial restriction that the official definition of webhooks only allows POST requests. Maybe we do not call it a hack but "Smart webhooks". Even a third GET scenario: from the web browser of my mobile phone I open a webhook url to trigger some action. |
|
Another advantage of enhancing the webhooks with GET, they do not need authentication. In the portal of my device I can only set an Action URL for events, but no additional data, like authentication. The device manufacturer provides here a possibility to set a webhook URL but he calls the URL using GET. |
|
@rohankapoorcom what is missing in this pull request, I noticed there is a tag "In progress"? |
|
@andre2007 I'm not sure about the tag. I believe it's set automatically and I cannot change it. This PR is waiting on nothing from me, it needs approval to be merged by the maintainers. |
|
We should not do GET. From my earlier comment to one of the linked PRs/issues:
We're not going to change the way we do things to solve 1 use case. |
|
Could you please at least provide me a workaround for my problem? The device manufacturer just let me enter an webhook URL which will be called using get. How can I use this as event similar to webhooks? |
Description:
We talked about this once before in #17782 and at the time it didn't make sense. Since then, we've run into at least one device (#19523) where the device only can make
GETcalls. Rather than making it configurable on a per webhook basis, I think it makes sense for all webhooks to respond with the same behavior whether it's aGETorPOSTcall.Related issue (if applicable): fixes #19523
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>
Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices: