vieles überarbeitet
This commit is contained in:
@@ -75,11 +75,11 @@ class Belevo_Server_Kommunikation extends IPSModule
|
||||
throw new Exception("Invalid action");
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
public function GetAction() {
|
||||
$json = $this->MakeJson();
|
||||
//$baseURL = $this->ReadPropertyString("BaseURL");
|
||||
$baseURL = "http://192.168.20.140:5000/influx?nr=";
|
||||
$baseURL = $this->ReadPropertyString("BaseURL");
|
||||
|
||||
$anlagenummer = $this->ReadPropertyString("Anlagenummer");
|
||||
|
||||
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()");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
public function GetAction() {
|
||||
$netzbezug = GetValue($this->ReadPropertyInteger("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);
|
||||
$this->SendJsonToInfluxDB($url);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
public function MakeJson() {
|
||||
@@ -115,19 +115,26 @@ $kontaktVolllast = $this->GetValue("Kontakt_Volllast");
|
||||
$this->SetValue("G_SK_5M_4", $kontaktVolllast);
|
||||
*/
|
||||
$netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug"));
|
||||
$an_nummer = GetProperty($this->ReadPropertyString("Anlagenummer");)
|
||||
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||
//$this->SetValue("E_PNB_5M_0", $netzbezug);
|
||||
|
||||
// Werte in ein Array packen
|
||||
$data = [
|
||||
|
||||
$influxData = array(
|
||||
|
||||
"Value" => array(
|
||||
"InfluxAllowed" => $InfluxJaNein // Setze InfluxAllowed auf true für den Test
|
||||
),
|
||||
//"Measurement" => $this->ReadPropertyString("Anlagenummer"),
|
||||
"Field" =>[
|
||||
"Parameter" => array($an_nummer
|
||||
),
|
||||
"Tracker" =array(
|
||||
//"G_BT_5M_0" => $this->GetValue("G_BT_5M_0"),
|
||||
//"G_SK_5M_3" => $this->GetValue("G_SK_5M_3"),
|
||||
//"G_SK_5M_4" => $this->GetValue("G_SK_5M_4"),
|
||||
"E_PNB_5M_0" => $netzbezug
|
||||
]
|
||||
];
|
||||
)
|
||||
);
|
||||
|
||||
// Array in JSON konvertieren
|
||||
$json = json_encode($data);
|
||||
@@ -167,16 +174,21 @@ return $json;
|
||||
}
|
||||
}
|
||||
*/
|
||||
private function SendJsonToInfluxDB($url)
|
||||
{
|
||||
private function SendJsonToInfluxDB($url, $jsonData) {
|
||||
// cURL Initialisieren
|
||||
$curl = curl_init();
|
||||
|
||||
// Optionen für cURL-Request definieren
|
||||
// Nur die erforderlichen Optionen setzen
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $url,
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user