vieles überarbeitet
This commit is contained in:
@@ -75,11 +75,11 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
throw new Exception("Invalid action");
|
throw new Exception("Invalid action");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public function GetAction() {
|
public function GetAction() {
|
||||||
$json = $this->MakeJson();
|
$json = $this->MakeJson();
|
||||||
//$baseURL = $this->ReadPropertyString("BaseURL");
|
$baseURL = $this->ReadPropertyString("BaseURL");
|
||||||
$baseURL = "http://192.168.20.140:5000/influx?nr=";
|
|
||||||
$anlagenummer = $this->ReadPropertyString("Anlagenummer");
|
$anlagenummer = $this->ReadPropertyString("Anlagenummer");
|
||||||
|
|
||||||
if (!empty($anlagenummer) && !empty($json)) {
|
if (!empty($anlagenummer) && !empty($json)) {
|
||||||
@@ -92,15 +92,15 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Keine Aufzeichnung im Influx: Anlagenummer oder JSON-Daten fehlen->GetAction()");
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Keine Aufzeichnung im Influx: Anlagenummer oder JSON-Daten fehlen->GetAction()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
public function GetAction() {
|
public function GetAction() {
|
||||||
$netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug"));
|
$netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug"));
|
||||||
$url = "http://192.168.20.140:5000/influx?id=test&E_PNB_5M_0=".$netzbezug;
|
$url = "http://192.168.20.140:5000/influx?id=test&E_PNB_5M_0=".$netzbezug;
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Sende Anfrage an URL: ".$url);
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Sende Anfrage an URL: ".$url);
|
||||||
$this->SendJsonToInfluxDB($url);
|
$this->SendJsonToInfluxDB($url);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
public function MakeJson() {
|
public function MakeJson() {
|
||||||
@@ -115,19 +115,26 @@ $kontaktVolllast = $this->GetValue("Kontakt_Volllast");
|
|||||||
$this->SetValue("G_SK_5M_4", $kontaktVolllast);
|
$this->SetValue("G_SK_5M_4", $kontaktVolllast);
|
||||||
*/
|
*/
|
||||||
$netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug"));
|
$netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug"));
|
||||||
|
$an_nummer = GetProperty($this->ReadPropertyString("Anlagenummer");)
|
||||||
|
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||||
//$this->SetValue("E_PNB_5M_0", $netzbezug);
|
//$this->SetValue("E_PNB_5M_0", $netzbezug);
|
||||||
|
|
||||||
// Werte in ein Array packen
|
// Werte in ein Array packen
|
||||||
$data = [
|
$influxData = array(
|
||||||
|
|
||||||
|
"Value" => array(
|
||||||
|
"InfluxAllowed" => $InfluxJaNein // Setze InfluxAllowed auf true für den Test
|
||||||
|
),
|
||||||
//"Measurement" => $this->ReadPropertyString("Anlagenummer"),
|
//"Measurement" => $this->ReadPropertyString("Anlagenummer"),
|
||||||
"Field" =>[
|
"Parameter" => array($an_nummer
|
||||||
|
),
|
||||||
|
"Tracker" =array(
|
||||||
//"G_BT_5M_0" => $this->GetValue("G_BT_5M_0"),
|
//"G_BT_5M_0" => $this->GetValue("G_BT_5M_0"),
|
||||||
//"G_SK_5M_3" => $this->GetValue("G_SK_5M_3"),
|
//"G_SK_5M_3" => $this->GetValue("G_SK_5M_3"),
|
||||||
//"G_SK_5M_4" => $this->GetValue("G_SK_5M_4"),
|
//"G_SK_5M_4" => $this->GetValue("G_SK_5M_4"),
|
||||||
"E_PNB_5M_0" => $netzbezug
|
"E_PNB_5M_0" => $netzbezug
|
||||||
]
|
)
|
||||||
];
|
);
|
||||||
|
|
||||||
// Array in JSON konvertieren
|
// Array in JSON konvertieren
|
||||||
$json = json_encode($data);
|
$json = json_encode($data);
|
||||||
@@ -167,16 +174,21 @@ return $json;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
private function SendJsonToInfluxDB($url)
|
private function SendJsonToInfluxDB($url, $jsonData) {
|
||||||
{
|
|
||||||
// cURL Initialisieren
|
// cURL Initialisieren
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
|
||||||
// Optionen für cURL-Request definieren
|
// Optionen für cURL-Request definieren
|
||||||
// Nur die erforderlichen Optionen setzen
|
|
||||||
curl_setopt_array($curl, [
|
curl_setopt_array($curl, [
|
||||||
CURLOPT_URL => $url,
|
CURLOPT_URL => $url,
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_POST => true, // POST-Methode verwenden
|
||||||
|
CURLOPT_HTTPHEADER => [
|
||||||
|
'Content-Type: application/json', // Header für JSON-Daten setzen
|
||||||
|
'Accept: application/json'
|
||||||
|
'id : test'
|
||||||
|
],
|
||||||
|
CURLOPT_POSTFIELDS => $jsonData // JSON-Daten als POST-Feld senden
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// cURL-Request ausführen
|
// cURL-Request ausführen
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "0.65",
|
"version": "0.66",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user