IPS als "HTTP-Server" (?)

Guten Morgen,

ein Gerät ließe sich über HTTP steuern. Dazu heißt es in der diesbezüglichen Beschreibung:

"Third-party application can interact with the Gateway through HTTP commands. To do so, the user first needs to enable the „local HTTP API“ function and set a proper HTTP server address on the Gateway’s admin page. The format of the HTTP server address should be http://Your_Server_Domain_or_IP_address: Service_Port/Path. Some examples are http://www.xxxxxx.com:80/a/b/c , http://192.168.1.101:8080/ , http://192.168.1.101 .

After the local HTTP API function is enabled and a correct server URL is set, the Gateway will automatically connect to the HTTP server. Then when the status of the end devices under the Gateway changes, the Gateway will send the device status data in JSON format to the HTTP server via a HTTP POST request."

Leider habe ich nichts dazu gefunden, ob und wie sich dies mit IPS realisieren ließe. Kann jemand weiterhelfen?

Vielen Dank und Grüße…

Möchtest du nur Daten empfangen oder auch Befehle senden? Empfangen müsste ja eigentlich über einen webhook funktionieren. Stichwort JSON Encoder und Webhook…

Viele Grüße
Stephan

Einrichten eines webhook inklusive Beispiel Skript aus der Doku nutzen zum testen.
Die Daten sollten dann als JSON bei RAW landen.

Michael

Vielen Dank Ihr beiden - das nutze ich bereits an anderer Stelle und versuche das auch hier mal…

Empfagen funktioniert über den Webhook nun prima. Um Befehle senden zu können, heißt es in der Beschreibung

"Third-party application can send commands to the Gateway’s URL via HTTP POST requests to
control the end devices. The Gateway’s URL is http://Your_Gateway_IP_Address/api.shtml.
HTTP Header:
{
POST /api.shtml HTTP/1.1
Content-Type: application/json
Content-Length: 78
Host: 192.168.1.107
Connection: close
}
HTTP Data:
{„dev_id“:„aaaabbbbccccdddd“,……}"

Habt Ihr auch eine Ahnung, wie ich diese Richtung in php realisiere (curl?)?

Noch einmal vielen Dank und Grüße…

So scheint es zu funktionieren:

$data = array(
"dev_id"=>"aaaabbbbccccdddd",
"…"=>"…");                                                                    
$data_string = json_encode($data);                                                                                   
                                                                                                                     
$ch = curl_init('http://Your_Gateway_IP_Address/api.shtml');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
'POST /api.shtml HTTP/1.1', 
'Content-Type: application/json',
'Content-Length: 78',
'Host: 192.168.1.107',
'Connection: close' . strlen($data_string))                                                                       
);                                                                                                                   
                                                                                                                     
$result = curl_exec($ch);