evt Fehler behoben
This commit is contained in:
@@ -15,6 +15,8 @@ class Belevo_Server_Kommunikation extends IPSModule
|
||||
|
||||
// JSON-String für Zusatzvariablen
|
||||
$this->RegisterPropertyString("ZusatzVariablen", json_encode([]));
|
||||
$this->RegisterPropertyString("Variable","0");
|
||||
$this->RegisterPropertyString("Variablenname","0");
|
||||
|
||||
// Timer registrieren
|
||||
$this->RegisterTimer("Timer_Influx", 0, 'IPS_RequestAction(' . $this->InstanceID . ', "GetAction", "");');
|
||||
@@ -32,8 +34,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
||||
$this->SetTimerInterval("Timer_Influx", 5000); // Alle 5 Sekunden
|
||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Influx Ja");
|
||||
|
||||
// Verarbeite die Zusatzvariablen
|
||||
$this->ProcessZusatzVariablen();
|
||||
|
||||
|
||||
} else {
|
||||
// Timer stoppen
|
||||
@@ -47,6 +48,9 @@ class Belevo_Server_Kommunikation extends IPSModule
|
||||
// Abrufen der ZusatzVariablen-Liste
|
||||
$zusatzVariablen = json_decode($this->ReadPropertyString("ZusatzVariablen"), true); // JSON decodieren
|
||||
|
||||
// Array für die Ausgabe erstellen
|
||||
$output = array();
|
||||
|
||||
// Verarbeitung der Variablen
|
||||
if (!empty($zusatzVariablen)) {
|
||||
foreach ($zusatzVariablen as $variable) {
|
||||
@@ -55,16 +59,22 @@ class Belevo_Server_Kommunikation extends IPSModule
|
||||
|
||||
// Überprüfen, ob die Variable existiert
|
||||
if (IPS_VariableExists($variableID)) {
|
||||
$wert = GetValue($variableID);
|
||||
$wert = GetValue($variableID); // Den aktuellen Wert der Zusatzvariable abrufen
|
||||
IPS_LogMessage("ZusatzVariable", "Name: $variablenname, ID: $variableID, Wert: $wert");
|
||||
|
||||
// Hier können Sie den Wert in die InfluxDB schreiben oder weiterverarbeiten
|
||||
// Beispiel: $this->WriteToInfluxDB($variablenname, $wert);
|
||||
// Wert dem Variablenname zuweisen
|
||||
$output[$variablenname] = $wert;
|
||||
} else {
|
||||
IPS_LogMessage("ZusatzVariable", "Variable mit ID $variableID existiert nicht.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: Ausgabe im JSON-Format protokollieren
|
||||
IPS_LogMessage("OutputJSON", json_encode($output));
|
||||
|
||||
// Wenn gewünscht, kannst du das JSON zurückgeben oder speichern
|
||||
return json_encode($output);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +91,10 @@ class Belevo_Server_Kommunikation extends IPSModule
|
||||
}
|
||||
|
||||
public function GetAction() {
|
||||
$json = $this->MakeJson();
|
||||
$output = $this->ProcessZusatzVariablen();
|
||||
$json = $this->MakeJson($output);
|
||||
// Verarbeite die Zusatzvariablen
|
||||
|
||||
$baseURL = $this->ReadPropertyString("BaseURL");
|
||||
|
||||
$anlagenummer = $this->ReadPropertyString("Anlagenummer");
|
||||
@@ -98,7 +111,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
||||
}
|
||||
|
||||
// Werte in ein Array packen
|
||||
public function MakeJson()
|
||||
public function MakeJson($a)
|
||||
{
|
||||
$an_nummer = $this->ReadPropertyString("Anlagenummer"); // Anlagenummer lesen
|
||||
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||
@@ -111,31 +124,10 @@ public function MakeJson()
|
||||
"Parameter" => array(
|
||||
"Influxadr" => $an_nummer
|
||||
),
|
||||
"Tracker" => array() // Initialisiere Tracker als leeres Array
|
||||
"Tracker" => $a // Initialisiere Tracker als leeres Array
|
||||
);
|
||||
|
||||
// Zusatzvariablen aus dem JSON-String abrufen und dekodieren
|
||||
$zusatzVariablenJson = $this->ReadPropertyString("ZusatzVariablen");
|
||||
$zusatzVariablen = json_decode($zusatzVariablenJson, true); // JSON in Array dekodieren
|
||||
|
||||
// Protokolliere den Inhalt der Zusatzvariablen
|
||||
IPS_LogMessage("MakeJson", "Zusatzvariablen JSON: " . $zusatzVariablenJson);
|
||||
|
||||
// Dynamisch Zusatzvariablen zum Tracker hinzufügen
|
||||
if (!empty($zusatzVariablen)) {
|
||||
foreach ($zusatzVariablen as $variable) {
|
||||
$variablenname = $variable['Variablenname'];
|
||||
$variableID = $variable['Variable'];
|
||||
|
||||
// Überprüfen, ob die Variable existiert
|
||||
if (IPS_VariableExists($variableID)) {
|
||||
$wert = GetValue($variableID); // Den aktuellen Wert der Zusatzvariable abrufen
|
||||
$influxData['Tracker'][$variablenname] = $wert; // Wert zum Tracker hinzufügen
|
||||
} else {
|
||||
IPS_LogMessage("MakeJson", "Variable mit ID $variableID existiert nicht.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Array in JSON konvertieren
|
||||
$json = json_encode($influxData);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"compatibility": {
|
||||
"version": "7.1"
|
||||
},
|
||||
"version": "0.80",
|
||||
"version": "0.82",
|
||||
"build": 0,
|
||||
"date": 0
|
||||
}
|
||||
Reference in New Issue
Block a user