no message
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
# Manager_1
|
||||
Beschreibung des Moduls.
|
||||
|
||||
### Inhaltsverzeichnis
|
||||
|
||||
1. [Funktionsumfang](#1-funktionsumfang)
|
||||
2. [Voraussetzungen](#2-voraussetzungen)
|
||||
3. [Software-Installation](#3-software-installation)
|
||||
4. [Einrichten der Instanzen in IP-Symcon](#4-einrichten-der-instanzen-in-ip-symcon)
|
||||
5. [Statusvariablen und Profile](#5-statusvariablen-und-profile)
|
||||
6. [WebFront](#6-webfront)
|
||||
7. [PHP-Befehlsreferenz](#7-php-befehlsreferenz)
|
||||
|
||||
### 1. Funktionsumfang
|
||||
|
||||
*
|
||||
|
||||
### 2. Voraussetzungen
|
||||
|
||||
- IP-Symcon ab Version 7.1
|
||||
|
||||
### 3. Software-Installation
|
||||
|
||||
* Über den Module Store das 'Manager_1'-Modul installieren.
|
||||
* Alternativ über das Module Control folgende URL hinzufügen
|
||||
|
||||
### 4. Einrichten der Instanzen in IP-Symcon
|
||||
|
||||
Unter 'Instanz hinzufügen' kann das 'Manager_1'-Modul mithilfe des Schnellfilters gefunden werden.
|
||||
- Weitere Informationen zum Hinzufügen von Instanzen in der [Dokumentation der Instanzen](https://www.symcon.de/service/dokumentation/konzepte/instanzen/#Instanz_hinzufügen)
|
||||
|
||||
__Konfigurationsseite__:
|
||||
|
||||
Name | Beschreibung
|
||||
-------- | ------------------
|
||||
|
|
||||
|
|
||||
|
||||
### 5. Statusvariablen und Profile
|
||||
|
||||
Die Statusvariablen/Kategorien werden automatisch angelegt. Das Löschen einzelner kann zu Fehlfunktionen führen.
|
||||
|
||||
#### Statusvariablen
|
||||
|
||||
Name | Typ | Beschreibung
|
||||
------ | ------- | ------------
|
||||
| |
|
||||
| |
|
||||
|
||||
#### Profile
|
||||
|
||||
Name | Typ
|
||||
------ | -------
|
||||
|
|
||||
|
|
||||
|
||||
### 6. WebFront
|
||||
|
||||
Die Funktionalität, die das Modul im WebFront bietet.
|
||||
|
||||
### 7. PHP-Befehlsreferenz
|
||||
|
||||
`boolean GEF_BeispielFunktion(integer $InstanzID);`
|
||||
Erklärung der Funktion.
|
||||
|
||||
Beispiel:
|
||||
`GEF_BeispielFunktion(12345);`
|
||||
@@ -1,67 +0,0 @@
|
||||
{
|
||||
"elements":[
|
||||
{
|
||||
"type":"Label",
|
||||
"caption":"Influx Punkte"
|
||||
},
|
||||
{
|
||||
"type":"Select",
|
||||
"name":"InfluxJaNein",
|
||||
"caption":"Influx Aufzeichnen Ja oder Nein",
|
||||
"options":[
|
||||
{
|
||||
"caption":"Ja",
|
||||
"value":true
|
||||
},
|
||||
{
|
||||
"caption":"Nein",
|
||||
"value":false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type":"ValidationTextBox",
|
||||
"name":"Anlagenummer",
|
||||
"caption":"Influxadresse",
|
||||
"suffix":"",
|
||||
"validate":"^An_\\d{4}$"
|
||||
},
|
||||
{
|
||||
"type":"ValidationTextBox",
|
||||
"name":"Gerätenummer",
|
||||
"caption":"Gerätenummer"
|
||||
},
|
||||
{
|
||||
"type":"ValidationTextBox",
|
||||
"name":"Ortschaft",
|
||||
"caption":"Ortschaft"
|
||||
},
|
||||
{
|
||||
"type":"List",
|
||||
"name":"ZusatzVariablen",
|
||||
"caption":"Zusätzliche Datenpunkte für Influxaufzeichnung",
|
||||
"add":true,
|
||||
"delete":true,
|
||||
"columns":[
|
||||
{
|
||||
"caption":"Influx Name",
|
||||
"name":"Variablenname",
|
||||
"width":"200px",
|
||||
"add":"",
|
||||
"edit":{
|
||||
"type":"ValidationTextBox"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption":"Datenpunkt",
|
||||
"name":"Variable",
|
||||
"width":"300px",
|
||||
"add":0,
|
||||
"edit":{
|
||||
"type":"SelectVariable"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"id": "{C300EE71-B955-5ED4-7FE5-393B7030158B}",
|
||||
"name": "Belevo_Server_K",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Belevo_Server_K extends IPSModule
|
||||
{
|
||||
public function Create()
|
||||
{
|
||||
// Die Standard-Create() Methode aufrufen
|
||||
parent::Create();
|
||||
|
||||
// Registrierung der Eigenschaften
|
||||
$this->RegisterPropertyString(
|
||||
"BaseURL",
|
||||
"https://brain.belevo.ch/storedata"
|
||||
);
|
||||
$this->RegisterPropertyString("Anlagenummer", "0");
|
||||
$this->RegisterPropertyBoolean("InfluxJaNein", false);
|
||||
|
||||
// JSON-String für Zusatzvariablen
|
||||
$this->RegisterPropertyString("ZusatzVariablen", json_encode([])); // Bezeichnung der Liste
|
||||
$this->RegisterPropertyString("Variable", "0"); // Datenpunkt kann im Syncom ausgewählt werden
|
||||
$this->RegisterPropertyString("Variablenname", "0"); // Name für Influxaufzeichnung
|
||||
$this->RegisterPropertyString("Gerätenummer", "0");
|
||||
$this->RegisterPropertyString("Ortschaft", "0");
|
||||
|
||||
$this->RegisterVariableInteger(
|
||||
"Wolkenwarscheinlichkeit",
|
||||
"Wolkenwarscheinlichkeit"
|
||||
);
|
||||
$this->RegisterVariableInteger("Temperatur", "Temperatur");
|
||||
|
||||
// Timer registrieren
|
||||
$this->RegisterTimer(
|
||||
"Timer_Influx",
|
||||
0,
|
||||
"IPS_RequestAction(" . $this->InstanceID . ', "GetAction", "");'
|
||||
);
|
||||
}
|
||||
|
||||
public function ApplyChanges()
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
|
||||
// Holen Sie sich die Einstellung, ob Influx aktiviert ist
|
||||
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||
|
||||
if ($InfluxJaNein) {
|
||||
// Timer auf 5 Minuten setzen
|
||||
$this->SetTimerInterval("Timer_Influx", 300000); // Alle 5 Minuten -> 5*60*1000=300000
|
||||
} else {
|
||||
// Timer stoppen
|
||||
$this->SetTimerInterval("Timer_Influx", 0);
|
||||
}
|
||||
}
|
||||
|
||||
public function getWetter($bn, $pw, $loc)
|
||||
{
|
||||
// URL mit Parametern zusammenstellen
|
||||
$url =
|
||||
"https://brain.belevo.ch/v2wetter?loc=" .
|
||||
urlencode($loc) .
|
||||
"&nr=" .
|
||||
urlencode($bn);
|
||||
|
||||
// HTTP-Anfrage-Header einstellen
|
||||
$headers = ["id: $pw"];
|
||||
|
||||
// cURL-Initialisierung
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
// HTTP-Anfrage ausführen und Antwort erhalten
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// Antwort in ein Array dekodieren
|
||||
$data = json_decode($response, true);
|
||||
|
||||
// Überprüfen, ob die benötigten Felder vorhanden sind und zurückgeben
|
||||
if (
|
||||
isset($data["forecast"]["forecastday"][0]["hour"][5]["temp_c"]) &&
|
||||
isset($data["forecast"]["forecastday"][0]["hour"][8]["cloud"])
|
||||
) {
|
||||
return [
|
||||
"temp" =>
|
||||
$data["forecast"]["forecastday"][0]["hour"][5]["temp_c"],
|
||||
"cloud" =>
|
||||
$data["forecast"]["forecastday"][0]["hour"][8]["cloud"],
|
||||
];
|
||||
}
|
||||
|
||||
// Fehlerbehandlung
|
||||
return null;
|
||||
}
|
||||
|
||||
private function ProcessZusatzVariablen()
|
||||
{
|
||||
// Abrufen der ZusatzVariablen-Liste
|
||||
$zusatzVariablen = json_decode(
|
||||
$this->ReadPropertyString("ZusatzVariablen"),
|
||||
true
|
||||
); // JSON decodieren
|
||||
|
||||
// Array für die Ausgabe erstellen
|
||||
$output = [];
|
||||
|
||||
// Verarbeitung der Variablen
|
||||
if (!empty($zusatzVariablen)) {
|
||||
foreach ($zusatzVariablen as $variable) {
|
||||
// Überprüfen, ob der Variablenname gesetzt ist
|
||||
if (isset($variable["Variablenname"])) {
|
||||
$variablenname = $variable["Variablenname"];
|
||||
} else {
|
||||
IPS_LogMessage(
|
||||
"Belevo_Server_Kommunikation",
|
||||
"Variablenname nicht gesetzt für die Variable: " .
|
||||
json_encode($variable)
|
||||
);
|
||||
continue; // Mit der nächsten Variable fortfahren
|
||||
}
|
||||
|
||||
$variableID = $variable["Variable"];
|
||||
|
||||
// Überprüfen, ob die Variable existiert
|
||||
if (IPS_VariableExists($variableID)) {
|
||||
$wert = GetValue($variableID); // Den aktuellen Wert der Zusatzvariable abrufen
|
||||
|
||||
// Wert dem Variablenname zuweisen
|
||||
$output[$variablenname] = $wert;
|
||||
} else {
|
||||
IPS_LogMessage(
|
||||
"Belevo_Server_Kommunikation",
|
||||
"Variable mit ID $variableID existiert nicht."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wenn gewünscht, kannst du das JSON zurückgeben oder speichern
|
||||
return json_encode($output);
|
||||
}
|
||||
|
||||
public function RequestAction($Ident, $Value)
|
||||
{
|
||||
switch ($Ident) {
|
||||
case "GetAction":
|
||||
$this->GetAction();
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid action");
|
||||
}
|
||||
}
|
||||
|
||||
public function GetAction()
|
||||
{
|
||||
$output = $this->ProcessZusatzVariablen();
|
||||
$json = $this->MakeJson($output);
|
||||
// Verarbeite die Zusatzvariablen
|
||||
|
||||
$baseURL = $this->ReadPropertyString("BaseURL");
|
||||
|
||||
$anlagenummer = $this->ReadPropertyString("Anlagenummer");
|
||||
|
||||
$answer = $this->getWetter(
|
||||
$anlagenummer,
|
||||
$this->ReadPropertyString("Gerätenummer"),
|
||||
$this->ReadPropertyString("Ortschaft")
|
||||
);
|
||||
|
||||
//$this->SetValue("Temperatur", $answer['temp']);
|
||||
//$this->SetValue("Wolkenwarscheinlichkeit", $answer['cloud']);
|
||||
if (isset($answer["temp"])) {
|
||||
$this->SetValue("Temperatur", $answer["temp"]);
|
||||
} else {
|
||||
IPS_LogMessage(
|
||||
"Belevo_Server_Kommunikation",
|
||||
"Temperatur-Wert ist nicht vorhanden."
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($answer["cloud"])) {
|
||||
$this->SetValue("Wolkenwarscheinlichkeit", $answer["cloud"]);
|
||||
} else {
|
||||
IPS_LogMessage(
|
||||
"Belevo_Server_Kommunikation",
|
||||
"Wolkenwarscheinlichkeit-Wert ist nicht vorhanden."
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($json)) {
|
||||
// Kombiniere die URL mit der Anlagenummer
|
||||
$fullURL = $baseURL;
|
||||
$this->SendJsonToInfluxDB($fullURL, $json);
|
||||
} else {
|
||||
IPS_LogMessage(
|
||||
"Belevo_Server_Kommunikation",
|
||||
"Keine Aufzeichnung im Influx: Anlagenummer oder JSON-Daten fehlen"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function MakeJson($json)
|
||||
{
|
||||
$an_nummer = $this->ReadPropertyString("Anlagenummer"); // Anlagenummer lesen
|
||||
$InfluxJaNein = $this->ReadPropertyBoolean("InfluxJaNein");
|
||||
|
||||
// Werte in ein Array packen
|
||||
$influxData = [
|
||||
"Value" => [
|
||||
"InfluxAllowed" => $InfluxJaNein, // Setze InfluxAllowed
|
||||
],
|
||||
"Parameter" => [
|
||||
"Influxadr" => $an_nummer,
|
||||
],
|
||||
"Tracker" => $json, // Initialisiere Tracker als leeres Array
|
||||
];
|
||||
|
||||
// Array in JSON konvertieren
|
||||
$json = json_encode($influxData);
|
||||
|
||||
// JSON zurückgeben oder weiterverarbeiten
|
||||
return $json;
|
||||
}
|
||||
|
||||
private function SendJsonToInfluxDB($url, $jsonData)
|
||||
{
|
||||
$pw = $this->ReadPropertyString("Gerätenummer");
|
||||
if (empty($pw)) {
|
||||
IPS_LogMessage(
|
||||
"Belevo_Server_Kommunikation",
|
||||
"Fehler: Gerätenummer ist leer."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// cURL Initialisieren
|
||||
$curl = curl_init();
|
||||
// Optionen für cURL-Request definieren
|
||||
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:" . $pw,
|
||||
],
|
||||
CURLOPT_POSTFIELDS => $jsonData, // JSON-Daten als POST-Feld senden
|
||||
]);
|
||||
|
||||
// cURL-Request ausführen
|
||||
$result = curl_exec($curl);
|
||||
|
||||
$error = curl_error($curl);
|
||||
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
// cURL beenden
|
||||
curl_close($curl);
|
||||
|
||||
if ($error) {
|
||||
IPS_LogMessage(
|
||||
"Belevo_Server_Kommunikation",
|
||||
"Fehler beim Senden an Influx: " . $error
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -19,7 +19,6 @@ class Pufferspeicher extends IPSModule
|
||||
$this->RegisterPropertyInteger("MaxAT_Temp", 20);
|
||||
$this->RegisterPropertyInteger("MinAT_Temp", 0);
|
||||
$this->RegisterPropertyBoolean("Puffertemperatur_glätten", false);
|
||||
$this->RegisterPropertyString("Zeitplan", "");
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
|
||||
// Puffer spezifische Variablen
|
||||
@@ -53,7 +52,7 @@ class Pufferspeicher extends IPSModule
|
||||
parent::ApplyChanges();
|
||||
$this->SetTimerInterval("Timer_Do_UserCalc_Boiler",$this->ReadPropertyInteger("Interval")*1000);
|
||||
}
|
||||
|
||||
|
||||
public function RequestAction($Ident, $Value)
|
||||
{
|
||||
switch ($Ident) {
|
||||
|
||||
Reference in New Issue
Block a user