mirror of
https://github.com/jomjol/AI-on-the-edge-device-docs.git
synced 2025-12-06 19:46:56 +03:00
added webhook doc (#62)
* added webhook doc * Update docs/Webhook.md * Update docs/Webhook.md --------- Co-authored-by: CaCO3 <caco3@ruinelli.ch>
This commit is contained in:
@@ -1,13 +1,60 @@
|
|||||||
# Webhook
|
# Webhook
|
||||||
|
|
||||||
Comming soon.
|
Comming soon.
|
||||||
See [https://github.com/jomjol/AI-on-the-edge-device/pull/3163](https://github.com/jomjol/AI-on-the-edge-device/pull/3163) and [https://github.com/jomjol/AI-on-the-edge-device/pull/3174](https://github.com/jomjol/AI-on-the-edge-device/pull/3174)
|
|
||||||
|
|
||||||
@RaHehl Please add some explanations.
|
## Purpose
|
||||||
Also I think it would be great to add the PHP examples:
|
|
||||||
|
The idea behind this webhook feature is to provide an alternative to MQTT and InfluxDB for transmitting data, such as water meter readings from a vacation home, to a standard PHP webspace.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
To configure the webhook feature, you only need to define a URI and an API key. The URI is where the webhook will send the data, and the API key is used to authenticate the requests, ensuring that only authorized devices can send data to your server.
|
||||||
|
|
||||||
|
## Example of a POST Request
|
||||||
|
|
||||||
|
Below is an example of the JSON payload that might be sent in a POST request to the webhook:
|
||||||
|
|
||||||
|
### Request Headers
|
||||||
|
|
||||||
|
```http
|
||||||
|
APIKEY: your-api-key-here
|
||||||
|
```
|
||||||
|
|
||||||
|
### JSON Payload
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"timeUTC": 1723196684,
|
||||||
|
"timestamp": "2024-08-09T11:44:44+0200",
|
||||||
|
"name": "main",
|
||||||
|
"rawValue": "0345.42647",
|
||||||
|
"value": "345.42648",
|
||||||
|
"preValue": "345.42648",
|
||||||
|
"rate": "0.000000",
|
||||||
|
"changeAbsolute": "0.00000",
|
||||||
|
"error": "no error"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timeUTC": 1723196684,
|
||||||
|
"timestamp": "2024-08-09T11:44:44+0200",
|
||||||
|
"name": "test",
|
||||||
|
"rawValue": "34",
|
||||||
|
"value": "34",
|
||||||
|
"preValue": "34",
|
||||||
|
"rate": "0.000000",
|
||||||
|
"changeAbsolute": "0",
|
||||||
|
"error": "no error"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Basic PHP Example
|
||||||
|
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
<?php
|
<?php
|
||||||
$expectedApiKey = 'testtest2';
|
$expectedApiKey = 'your-api-key-here';
|
||||||
|
|
||||||
$receivedApiKey = isset($_SERVER['HTTP_APIKEY']) ? $_SERVER['HTTP_APIKEY'] : '';
|
$receivedApiKey = isset($_SERVER['HTTP_APIKEY']) ? $_SERVER['HTTP_APIKEY'] : '';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user