hey,
i use an snom phone that is able to “call” an url when i press some buttons.
Would it be possible to use home assistant as an receiver? i would like to feed an sensor /switch wit that information.
thank u for ur help!
hey,
i use an snom phone that is able to “call” an url when i press some buttons.
Would it be possible to use home assistant as an receiver? i would like to feed an sensor /switch wit that information.
thank u for ur help!
AFAIK HA requires a POST request.
What I share here is a proof of concept where a web page button starts a “post”, but there still is a “POST” request in the process.
Define an automation (adjust notify.mobile_app_sm_a125f to your notification service)):
alias: Test Webhook
description: ""
trigger:
- platform: webhook
webhook_id: test_webhook
condition: []
action:
- service: notify.mobile_app_sm_a125f
data:
message: Test Webhook succes
mode: single
This implementation uses two implementations: the first refers to a fixed URL, the second constructs the webhook url from the user specified url which would allow you to reuse exactly the same code as long as the url changes.
<!doctype html>
<!-- File /config/www/test_webhook.html to open using http(s)://YOURINSTANCE:PORT/local/test_webhook.html -->
<html>
<head>
<title>Test Webhook</title>
</head>
<body>
<button onclick="fetch('/api/webhook/test_webhook',{method:'post'});">
Trigger automation "Test Webhook"
</button><br />
<button onclick="var w=location.href.substring(location.href.lastIndexOf('/') + 1);w=w.substring(0,w.lastIndexOf('.'));fetch('/api/webhook/' + w, {method:'post'});">
Trigger automation "Test Webhook" (generic method)
</button>
</body>
</html>
The above requires that the page is used by a client that executes the JavaScript code.
You can skip the requirement for pushing a button by executing JavaScript on page load.
As far as the parameters go, you’ll also need to amend this proof of concept to adjust the request headers (Content-Type) and convert the GET parameters to a payload.
For more info, read the documentation regarding webhooks .
thanks for ur reply.
i was able to build an html page that runs onload:
<!doctype html>
<!-- File /config/www/test_webhook.html to open using http(s)://YOURINSTANCE:PORT/local/test_webhook.html -->
<html>
<head>
<script type="text/javascript">
window.onload = function() {
fetch("http://ip:8123/api/webhook/webhook", { method: "POST", });
}
</script>
<title>Test Webhook</title>
</head>
<body>
test
</body>
</html>
so opening up that page on my webbrowser sends an message now to my mobile device.
but sadly i dont get any further then that… it seems like i need to adjust the call of the webhook so that the phone can run it
In 2023.5.1, webhooks can be called using GET, but wait a little bit before updating - there are quite a few issues with that first release of the month.
sadly snom phones doenst seem to like to call ssl pages… tried it several times but didnt worked
log show an error:
25/5/2023 11:54:57 [NOTICE] GUI: Sending post request https://domainnameofmyhomie:443/api/webhook/dndon
25/5/2023 11:54:57 [NOTICE] PHN: Fetching URL: https://domainnameofmyhomie:443/api/webhook/dndon
25/5/2023 11:54:57 [ERROR ] PHN: TPL: Socket Error: 78/21/connected, read -> Operation now in progress (150)
25/5/2023 11:54:57 [NOTICE] PHN: webclient::on_tcp_close conn_id:16
25/5/2023 11:54:57 [NOTICE] PHN: Server rejected Action URL request with 500 ><
That does seem to be related to SSL - I am accessing mine over SSL.
Check your home assistant log, maybe you find the reason.
Also, your request is a POST request - this thread is about GET requests.