Fehlerbehebung Server senden
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"id": "{21F800F4-A506-62C9-CF26-9CA652629C22}",
|
"id": "{9449616A-D571-8D4A-E917-A3DD338F00A6}",
|
||||||
"name": "Belevo_Server_Kommunikation",
|
"name": "Belevo_Server_Kommunikation",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"vendor": "Belevo AG",
|
"vendor": "Belevo AG",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
parent::Create();
|
parent::Create();
|
||||||
//Netzbezug
|
//Netzbezug
|
||||||
$this->RegisterPropertyFloat("E_PNB_5M_0", 0);
|
$this->RegisterPropertyFloat("E_PNB_5M_0", 0);
|
||||||
$this->RegisterVariableFloat("Netzbezug", "Netzbezug", "",0);
|
$this->RegisterPropertyFloat("Netzbezug", "", "",0);
|
||||||
/*//Boilerstatus
|
/*//Boilerstatus
|
||||||
$this->RegisterPropertyInteger("G_BS_5M_0", 0);
|
$this->RegisterPropertyInteger("G_BS_5M_0", 0);
|
||||||
$this->RegisterVariableInteger("Boilerstatus", 0);
|
$this->RegisterVariableInteger("Boilerstatus", 0);
|
||||||
@@ -43,6 +43,7 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
$this->RegisterPropertyBoolean("InfluxJaNein", false);
|
$this->RegisterPropertyBoolean("InfluxJaNein", false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->RegisterTimer("Timer_Influx", 0, 'IPS_RequestAction(' . $this->InstanceID . ', "GetAction", "");');// 5min = 1000 * 60 * 5 = 300'000ms
|
$this->RegisterTimer("Timer_Influx", 0, 'IPS_RequestAction(' . $this->InstanceID . ', "GetAction", "");');// 5min = 1000 * 60 * 5 = 300'000ms
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,10 +53,12 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||||
if ($InfluxJaNein) {
|
if ($InfluxJaNein) {
|
||||||
// Timer auf 5 Minuten setzen
|
// Timer auf 5 Minuten setzen
|
||||||
$this->SetTimerInterval("Timer_Influx", 300000);
|
$this->SetTimerInterval("Timer_Influx", 10000);//Alle 10 Sekunden
|
||||||
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Influx Ja");
|
||||||
} else {
|
} else {
|
||||||
// Timer stoppen
|
// Timer stoppen
|
||||||
$this->SetTimerInterval("Timer_Influx", 0);
|
$this->SetTimerInterval("Timer_Influx", 0);
|
||||||
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Influx Nein");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,19 +76,16 @@ class Belevo_Server_Kommunikation extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function GetAction() {
|
public function GetAction() {
|
||||||
|
|
||||||
$jaNeinAuswahl = $this->ReadPropertyBoolean("JaNeinAuswahl");
|
|
||||||
|
|
||||||
if ($jaNeinAuswahl) {
|
|
||||||
$json = $this->MakeJson();
|
$json = $this->MakeJson();
|
||||||
$baseURL = $this->ReadPropertyString("BaseURL");
|
$baseURL = $this->ReadPropertyString("BaseURL");
|
||||||
$anlagenummer = $this->ReadPropertyString("Anlagenummer");
|
$anlagenummer = $this->ReadPropertyString("Anlagenummer");
|
||||||
|
|
||||||
|
if (!empty($anlagenummer) && !empty($json)) {
|
||||||
// Kombiniere die URL mit der Anlagenummer
|
// Kombiniere die URL mit der Anlagenummer
|
||||||
$fullURL = $baseURL . $anlagenummer;
|
$fullURL = $baseURL . $anlagenummer;
|
||||||
$this->SendJsonToInfluxDB($fullURL, $json);
|
$this->SendJsonToInfluxDB($fullURL, $json);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Keine Aufzeichnung im Influx");
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Keine Aufzeichnung im Influx: Anlagenummer oder JSON-Daten fehlen->GetAction()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,12 +106,12 @@ $this->SetValue("E_PNB_5M_0", $netzbezug);
|
|||||||
|
|
||||||
// Werte in ein Array packen
|
// Werte in ein Array packen
|
||||||
$data = [
|
$data = [
|
||||||
"_measurement" => $this->ReadPropertyString("Anlagenummer"),
|
"measurement" => $this->ReadPropertyString("Anlagenummer"),
|
||||||
"_field" =>[
|
"field" =>[
|
||||||
//"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" => $this->GetValue("E_PNB_5M_0"),
|
"E_PNB_5M_0" => $netzbezug,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -126,13 +126,19 @@ return $json;
|
|||||||
|
|
||||||
private function SendJsonToInfluxDB($url, $json)
|
private function SendJsonToInfluxDB($url, $json)
|
||||||
{
|
{
|
||||||
$token = "iFNTONC5UvST8GT5itWqxiO6m4O1yHt5hus54J8eqotk5IZiq0Wjd0_Xi6dozmo32QR3esJqk6hJAvJ8X2SxtQ==";
|
// $token = "Token iFNTONC5UvST8GT5itWqxiO6m4O1yHt5hus54J8eqotk5IZiq0Wjd0_Xi6dozmo32QR3esJqk6hJAvJ8X2SxtQ==";
|
||||||
|
/*
|
||||||
|
if (empty($token)) {
|
||||||
|
IPS_LogMessage("Belevo_Server_Kommunikation", "InfluxDB-Token fehlt->SendJsonToInfluxDB");
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
$options = [
|
$options = [
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-Type: application/json\r\n".
|
'header' => "Content-Type: application/json\r\n".
|
||||||
"Authorization: Bearer $token\r\n",
|
"daten: $json".
|
||||||
|
"id: test\r\n",
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'content' => $json,
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
@@ -140,9 +146,9 @@ return $json;
|
|||||||
|
|
||||||
if ($result === FALSE) {
|
if ($result === FALSE) {
|
||||||
|
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Fehler beim senden an Influx");
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Fehler beim senden an Influx->SendJsonToInfluxDB()");
|
||||||
} else {
|
} else {
|
||||||
IPS_LogMessage("Belevo_Server_Kommunikation", "Daten erfolgreich an Influx gesendet");
|
IPS_LogMessage("Belevo_Server_Kommunikation", "Daten erfolgreich an Influx gesendet->SendJsonToInfluxDB()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"onClick": "ZAEHL_AdditionMethode($id);"
|
"onClick": "ZAEHL_AdditionMethode($id);"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Suptrahierer",
|
"type": "Button",
|
||||||
"caption": "Zähler zurücksetzen",
|
"caption": "Zähler zurücksetzen",
|
||||||
"onClick": "ZAEHL_Subtraktionsmethode($id);"
|
"onClick": "ZAEHL_Subtraktionsmethode($id);"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"id": "{{097D2D9F-2144-C47B-7755-6A0F93B24325}}",
|
||||||
|
"name": "Michisplayground",
|
||||||
|
"type": 3,
|
||||||
|
"vendor": "Belevo AG",
|
||||||
|
"parentRequirements": [],
|
||||||
|
"childRequirements": [],
|
||||||
|
"implemented": [],
|
||||||
|
"url": "",
|
||||||
|
"prefix": "ZAEHL"
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,46 @@
|
|||||||
|
|
||||||
class Michisplayground extends IPSModule {
|
class Michisplayground extends IPSModule {
|
||||||
|
|
||||||
|
// Konstruktor
|
||||||
|
public function __construct($InstanceID)
|
||||||
|
{
|
||||||
|
parent::__construct($InstanceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ApplyChanges()
|
||||||
|
{
|
||||||
|
parent::ApplyChanges();
|
||||||
|
|
||||||
|
// Registriere die Zählervariable, wenn sie nicht bereits existiert
|
||||||
|
if (!IPS_VariableExists($this->GetIDForIdent("Counter"))) {
|
||||||
|
$this->RegisterVariableInteger("Counter", "Zähler", "", 1);
|
||||||
|
SetValue($this->GetIDForIdent("Counter"), 0); // Setze den Zähler auf 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methode zum Erhöhen des Zählers
|
||||||
|
public function AdditionMethode()
|
||||||
|
{
|
||||||
|
$currentValue = GetValue($this->GetIDForIdent("Counter"));
|
||||||
|
$newValue = $currentValue + 1;
|
||||||
|
SetValue($this->GetIDForIdent("Counter"), $newValue);
|
||||||
|
IPS_LogMessage("ErweiterterZaehlerModul", "Zähler erhöht: " . $newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methode zum Zurücksetzen des Zählers
|
||||||
|
public function Subtraktionsmethode()
|
||||||
|
{
|
||||||
|
SetValue($this->GetIDForIdent("Counter"), 0);
|
||||||
|
IPS_LogMessage("ErweiterterZaehlerModul", "Zähler zurückgesetzt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methode zum Abfragen des Zählers
|
||||||
|
public function GetCounter()
|
||||||
|
{
|
||||||
|
$currentValue = GetValue($this->GetIDForIdent("Counter"));
|
||||||
|
IPS_LogMessage("ErweiterterZaehlerModul", "Aktueller Zählerstand: " . $currentValue);
|
||||||
|
return $currentValue; // Gibt den aktuellen Zählerstand zurück
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "0.33",
|
"version": "0.34",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user