Diverse veränderungen durchgefürt. Passwörte Prüfung vom SQL dazugenommen
This commit is contained in:
@@ -20,16 +20,21 @@
|
|||||||
"suffix": "",
|
"suffix": "",
|
||||||
"validate": "^An_\\d{4}$"
|
"validate": "^An_\\d{4}$"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "ValidationTextBox",
|
||||||
|
"name": "GeräteNummer",
|
||||||
|
"caption": "Gerätenummer"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "List",
|
"type": "List",
|
||||||
"name": "ZusatzVariablen",
|
"name": "ZusatzVariablen",
|
||||||
"caption": "Zusätzliche Variablen für Influx",
|
"caption": "Zusätzliche Datenpunkte für Influxaufzeichnung",
|
||||||
"add": true,
|
"add": true,
|
||||||
"delete": true,
|
"delete": true,
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
||||||
"caption": "Variablenname",
|
"caption": "Influx Name",
|
||||||
"name": "Variablenname",
|
"name": "Variablenname",
|
||||||
"width": "200px",
|
"width": "200px",
|
||||||
"add": "",
|
"add": "",
|
||||||
@@ -38,7 +43,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"caption": "Variable",
|
"caption": "Datenpunkt",
|
||||||
"name": "Variable",
|
"name": "Variable",
|
||||||
"width": "300px",
|
"width": "300px",
|
||||||
"add": 0,
|
"add": 0,
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
$this->RegisterPropertyBoolean("InfluxJaNein", false);
|
$this->RegisterPropertyBoolean("InfluxJaNein", false);
|
||||||
|
|
||||||
// JSON-String für Zusatzvariablen
|
// JSON-String für Zusatzvariablen
|
||||||
$this->RegisterPropertyString("ZusatzVariablen", json_encode([]));
|
$this->RegisterPropertyString("ZusatzVariablen", json_encode([]));// Bezeichnung der Liste
|
||||||
$this->RegisterPropertyString("Variable","0");
|
$this->RegisterPropertyString("Variable","0"); // Datenpunkt kann im Syncom ausgewählt werden
|
||||||
$this->RegisterPropertyString("Variablenname","0");
|
$this->RegisterPropertyString("Variablenname","0"); // Name für Influxaufzeichnung
|
||||||
|
$this->RegisterPropertyString("GeräteNummer","0");
|
||||||
|
|
||||||
// Timer registrieren
|
// Timer registrieren
|
||||||
$this->RegisterTimer("Timer_Influx", 0, 'IPS_RequestAction(' . $this->InstanceID . ', "GetAction", "");');
|
$this->RegisterTimer("Timer_Influx", 0, 'IPS_RequestAction(' . $this->InstanceID . ', "GetAction", "");');
|
||||||
@@ -31,7 +32,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
|
|
||||||
if ($InfluxJaNein) {
|
if ($InfluxJaNein) {
|
||||||
// Timer auf 5 Minuten setzen
|
// Timer auf 5 Minuten setzen
|
||||||
$this->SetTimerInterval("Timer_Influx", 5000); // Alle 5 Sekunden
|
$this->SetTimerInterval("Timer_Influx", 5000); // Alle 5 Minuten -> 5*60*1000=300000
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Influx Ja");
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Influx Ja");
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
// Überprüfen, ob die Variable existiert
|
// Überprüfen, ob die Variable existiert
|
||||||
if (IPS_VariableExists($variableID)) {
|
if (IPS_VariableExists($variableID)) {
|
||||||
$wert = GetValue($variableID); // Den aktuellen Wert der Zusatzvariable abrufen
|
$wert = GetValue($variableID); // Den aktuellen Wert der Zusatzvariable abrufen
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Name: $variablenname, ID: $variableID, Wert: $wert");
|
|
||||||
|
|
||||||
// Wert dem Variablenname zuweisen
|
// Wert dem Variablenname zuweisen
|
||||||
$output[$variablenname] = $wert;
|
$output[$variablenname] = $wert;
|
||||||
@@ -108,9 +109,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
|
|
||||||
if (!empty($json)) {
|
if (!empty($json)) {
|
||||||
// Kombiniere die URL mit der Anlagenummer
|
// Kombiniere die URL mit der Anlagenummer
|
||||||
$fullURL = $baseURL;
|
$fullURL = $baseURL
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "URL: ".$fullURL);
|
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "JSON: " . $json);
|
|
||||||
$this->SendJsonToInfluxDB($fullURL, $json);
|
$this->SendJsonToInfluxDB($fullURL, $json);
|
||||||
} else {
|
} else {
|
||||||
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()");
|
||||||
@@ -118,7 +117,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Werte in ein Array packen
|
// Werte in ein Array packen
|
||||||
public function MakeJson($a)
|
public function MakeJson($json)
|
||||||
{
|
{
|
||||||
$an_nummer = $this->ReadPropertyString("Anlagenummer"); // Anlagenummer lesen
|
$an_nummer = $this->ReadPropertyString("Anlagenummer"); // Anlagenummer lesen
|
||||||
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||||
@@ -131,14 +130,14 @@ public function MakeJson($a)
|
|||||||
"Parameter" => array(
|
"Parameter" => array(
|
||||||
"Influxadr" => $an_nummer
|
"Influxadr" => $an_nummer
|
||||||
),
|
),
|
||||||
"Tracker" => $a // Initialisiere Tracker als leeres Array
|
"Tracker" => $json // Initialisiere Tracker als leeres Array
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Array in JSON konvertieren
|
// Array in JSON konvertieren
|
||||||
$json = json_encode($influxData);
|
$json = json_encode($influxData);
|
||||||
IPS_LogMessage("MakeJson", "Erstelltes JSON: " . $json);
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Erstelltes JSON: " . $json);
|
||||||
|
|
||||||
// JSON zurückgeben oder weiterverarbeiten
|
// JSON zurückgeben oder weiterverarbeiten
|
||||||
return $json;
|
return $json;
|
||||||
@@ -149,7 +148,7 @@ public function MakeJson($a)
|
|||||||
private function SendJsonToInfluxDB($url, $jsonData) {
|
private function SendJsonToInfluxDB($url, $jsonData) {
|
||||||
// cURL Initialisieren
|
// cURL Initialisieren
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
$pw =$this->ReadPropertyString("Passwort");
|
||||||
// Optionen für cURL-Request definieren
|
// Optionen für cURL-Request definieren
|
||||||
curl_setopt_array($curl, [
|
curl_setopt_array($curl, [
|
||||||
CURLOPT_URL => $url,
|
CURLOPT_URL => $url,
|
||||||
@@ -158,7 +157,7 @@ private function SendJsonToInfluxDB($url, $jsonData) {
|
|||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
'Content-Type: application/json', // Header für JSON-Daten setzen
|
'Content-Type: application/json', // Header für JSON-Daten setzen
|
||||||
'Accept: application/json',
|
'Accept: application/json',
|
||||||
'id: test'
|
'id:'.$pw
|
||||||
],
|
],
|
||||||
CURLOPT_POSTFIELDS => $jsonData // JSON-Daten als POST-Feld senden
|
CURLOPT_POSTFIELDS => $jsonData // JSON-Daten als POST-Feld senden
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "0.84",
|
"version": "0.85",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user