statt ein, ein JSON-Strig verwendet für generisch dynamische werte
This commit is contained in:
@@ -5,47 +5,19 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
|
|
||||||
public function Create()
|
public function Create()
|
||||||
{
|
{
|
||||||
// Zweite Gleiche Variable wird in der Benutzeroberfläche von Symcon angezeigt
|
// Die Standard-Create() Methode aufrufen
|
||||||
//Variable: dynamische Daten
|
|
||||||
//Property: statische Konfigurationsdaten
|
|
||||||
parent::Create();
|
parent::Create();
|
||||||
//Netzbezug
|
|
||||||
$this->RegisterPropertyFloat("E_PNB_5M_0", 0);
|
// Registrierung der Eigenschaften
|
||||||
$this->RegisterPropertyInteger("Netzbezug", 0);
|
$this->RegisterPropertyString("BaseURL", "http://192.168.20.140:5000/influx");
|
||||||
/*//Boilerstatus
|
$this->RegisterPropertyString("Anlagenummer", "0");
|
||||||
$this->RegisterPropertyInteger("G_BS_5M_0", 0);
|
|
||||||
$this->RegisterPropertyInteger("Boilerstatus", 0);
|
|
||||||
//Boilertemperatur
|
|
||||||
$this->RegisterPropertyFloat("G_BT_5M_0",0); // Wird an Influx Server gesendet
|
|
||||||
$this->RegisterPropertyInteger("Boilertemperatur", 0); // Ist, Jetzige Boilertemperatur
|
|
||||||
//Schaltkontake des Boilers
|
|
||||||
$this->RegisterPropertyInteger("G_SK_5M_1",0);
|
|
||||||
$this->RegisterPropertyInteger("Schaltkontakt_1", 0);
|
|
||||||
$this->RegisterPropertyInteger("G_SK_5M_2",0);
|
|
||||||
$this->RegisterPropertyInteger("Schaltkontakt_2", 0);
|
|
||||||
//Schaltkontake des Boilers
|
|
||||||
$this->RegisterPropertyInteger("G_SK_5M_3",0);
|
|
||||||
$this->RegisterPropertyInteger("Kontakt_Teillast", 0);
|
|
||||||
$this->RegisterPropertyInteger("G_SK_5M_4",0);
|
|
||||||
$this->RegisterPropertyInteger("Kontakt_Volllast", 0);
|
|
||||||
//Wärmepumpe Status
|
|
||||||
$this->RegisterPropertyFloat("G_WPS_5M_0",0);
|
|
||||||
$this->RegisterPropertyInteger("Waermepumpe_Status", 0);
|
|
||||||
//Wolkenwahrscheinlichkeit
|
|
||||||
$this->RegisterPropertyFloat("G_WW_5M_0",0);
|
|
||||||
$this->RegisterPropertyInteger("Wolkenwahrscheinlichkeit", 0);
|
|
||||||
//Aussentemperatur
|
|
||||||
$this->RegisterPropertyFloat("G_AT_5M_0",0);
|
|
||||||
$this->RegisterPropertyInteger("Aussentemperatur", 0);
|
|
||||||
*/
|
|
||||||
//$this->RegisterPropertyString("BaseURL","https://brain.belevo.ch/status?nr=");
|
|
||||||
$this->RegisterPropertyString("BaseURL","http://192.168.20.140:5000/influx");
|
|
||||||
$this->RegisterPropertyString("Anlagenummer",0);
|
|
||||||
$this->RegisterPropertyBoolean("InfluxJaNein", false);
|
$this->RegisterPropertyBoolean("InfluxJaNein", false);
|
||||||
$this->RegisterPropertyArray("ZusatzVariablen",[]);
|
|
||||||
|
|
||||||
|
// JSON-String für Zusatzvariablen
|
||||||
|
$this->RegisterPropertyString("ZusatzVariablen", json_encode([]));
|
||||||
|
|
||||||
$this->RegisterTimer("Timer_Influx", 0, 'IPS_RequestAction(' . $this->InstanceID . ', "GetAction", "");');// 5min = 1000 * 60 * 5 = 300'000ms
|
// Timer registrieren
|
||||||
|
$this->RegisterTimer("Timer_Influx", 0, 'IPS_RequestAction(' . $this->InstanceID . ', "GetAction", "");');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ApplyChanges()
|
public function ApplyChanges()
|
||||||
@@ -60,7 +32,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
$this->SetTimerInterval("Timer_Influx", 5000); // Alle 5 Sekunden
|
$this->SetTimerInterval("Timer_Influx", 5000); // Alle 5 Sekunden
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Influx Ja");
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Influx Ja");
|
||||||
|
|
||||||
// Verarbeite die ZusatzVariablen
|
// Verarbeite die Zusatzvariablen
|
||||||
$this->ProcessZusatzVariablen();
|
$this->ProcessZusatzVariablen();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -71,9 +43,9 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function ProcessZusatzVariablen()
|
private function ProcessZusatzVariablen()
|
||||||
{
|
{
|
||||||
// Abrufen der ZusatzVariablen-Liste
|
// Abrufen der ZusatzVariablen-Liste
|
||||||
$zusatzVariablen = $this->ReadPropertyArray("ZusatzVariablen");
|
$zusatzVariablen = json_decode($this->ReadPropertyString("ZusatzVariablen"), true); // JSON decodieren
|
||||||
|
|
||||||
// Verarbeitung der Variablen
|
// Verarbeitung der Variablen
|
||||||
if (!empty($zusatzVariablen)) {
|
if (!empty($zusatzVariablen)) {
|
||||||
@@ -93,7 +65,8 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function RequestAction($Ident, $Value)
|
public function RequestAction($Ident, $Value)
|
||||||
@@ -127,13 +100,13 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
// Werte in ein Array packen
|
// Werte in ein Array packen
|
||||||
public function MakeJson()
|
public function MakeJson()
|
||||||
{
|
{
|
||||||
$an_nummer = $this->ReadPropertyString("Anlagenummer"); // Verwende ReadPropertyString, um die Anlagenummer zu lesen
|
$an_nummer = $this->ReadPropertyString("Anlagenummer"); // Anlagenummer lesen
|
||||||
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||||
|
|
||||||
// Werte in ein Array packen
|
// Werte in ein Array packen
|
||||||
$influxData = array(
|
$influxData = array(
|
||||||
"Value" => array(
|
"Value" => array(
|
||||||
"InfluxAllowed" => $InfluxJaNein // Setze InfluxAllowed auf true für den Test
|
"InfluxAllowed" => $InfluxJaNein // Setze InfluxAllowed
|
||||||
),
|
),
|
||||||
"Parameter" => array(
|
"Parameter" => array(
|
||||||
"Influxadr" => $an_nummer
|
"Influxadr" => $an_nummer
|
||||||
@@ -141,11 +114,12 @@ public function MakeJson()
|
|||||||
"Tracker" => array() // Initialisiere Tracker als leeres Array
|
"Tracker" => array() // Initialisiere Tracker als leeres Array
|
||||||
);
|
);
|
||||||
|
|
||||||
// Zusatzvariablen aus den Instanzeigenschaften abrufen
|
// Zusatzvariablen aus dem JSON-String abrufen und dekodieren
|
||||||
$zusatzVariablen = $this->ReadPropertyArray("ZusatzVariablen");
|
$zusatzVariablenJson = $this->ReadPropertyString("ZusatzVariablen");
|
||||||
|
$zusatzVariablen = json_decode($zusatzVariablenJson, true); // JSON in Array dekodieren
|
||||||
|
|
||||||
// Protokolliere den Inhalt der Zusatzvariablen
|
// Protokolliere den Inhalt der Zusatzvariablen
|
||||||
IPS_LogMessage("MakeJson", "Zusatzvariablen Array: " . json_encode($zusatzVariablen));
|
IPS_LogMessage("MakeJson", "Zusatzvariablen JSON: " . $zusatzVariablenJson);
|
||||||
|
|
||||||
// Dynamisch Zusatzvariablen zum Tracker hinzufügen
|
// Dynamisch Zusatzvariablen zum Tracker hinzufügen
|
||||||
if (!empty($zusatzVariablen)) {
|
if (!empty($zusatzVariablen)) {
|
||||||
@@ -163,12 +137,9 @@ public function MakeJson()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protokolliere den Inhalt des influxData-Arrays vor der JSON-Konvertierung
|
|
||||||
IPS_LogMessage("MakeJson", "InfluxData Array vor JSON-Konvertierung: " . json_encode($influxData));
|
|
||||||
|
|
||||||
// Array in JSON konvertieren
|
// Array in JSON konvertieren
|
||||||
$json = json_encode($influxData);
|
$json = json_encode($influxData);
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Erstelltes JSON: " . $json);
|
IPS_LogMessage("MakeJson", "Erstelltes JSON: " . $json);
|
||||||
|
|
||||||
// JSON zurückgeben oder weiterverarbeiten
|
// JSON zurückgeben oder weiterverarbeiten
|
||||||
return $json;
|
return $json;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "0.78",
|
"version": "0.79",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user