Initial commit
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -25,3 +25,8 @@
|
||||
/app/Config/database.php
|
||||
/vendors/*
|
||||
|
||||
# Module für vorlagen, Testzwecke...
|
||||
|
||||
/User_Template
|
||||
/Wechselrichter
|
||||
/CC100_HW
|
||||
67
Boiler_2_Stufig_Mit_Fueler/README.md
Normal file
67
Boiler_2_Stufig_Mit_Fueler/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# 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);`
|
||||
45
Boiler_2_Stufig_Mit_Fueler/form.json
Normal file
45
Boiler_2_Stufig_Mit_Fueler/form.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Konfiguration der nötigen Schaltkontakte und Nennleistungen"
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "IdleCounterMax",
|
||||
"caption": "Zyklen zwischen zwei Leisutungsänderungen",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "BoilerLeistungTeillast",
|
||||
"caption": "Leistug Teillast",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "BoilerLeistungVolllast",
|
||||
"caption": "Leistug Vollast",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Boilertemperatur",
|
||||
"caption": "Variable für Boilertemperatur",
|
||||
"test": true
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Kontakt_Teillast",
|
||||
"caption": "Schaltkontakt Teillast",
|
||||
"test": true
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Kontakt_Volllast",
|
||||
"caption": "Schaltkontakt Volllast",
|
||||
"test": true
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
7
Boiler_2_Stufig_Mit_Fueler/locale.json
Normal file
7
Boiler_2_Stufig_Mit_Fueler/locale.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"translations": {
|
||||
"de": {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Boiler_2_Stufig_Mit_Fueler/module.json
Normal file
12
Boiler_2_Stufig_Mit_Fueler/module.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{64ECCE9F-7757-0ABA-0B81-501108A25565}",
|
||||
"name": "Boiler_2_Stufig_Mit_Fueler",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
205
Boiler_2_Stufig_Mit_Fueler/module.php
Normal file
205
Boiler_2_Stufig_Mit_Fueler/module.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
class Boiler_2_Stufig_Mit_Fueler extends IPSModule {
|
||||
|
||||
public function Create() {
|
||||
parent::Create();
|
||||
|
||||
// Prioritäten
|
||||
$this->RegisterVariableInteger("LockPrio", "LockPrio");
|
||||
$this->RegisterVariableInteger("UserPrio", "UserPrio");
|
||||
|
||||
// Energiehandling
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0);
|
||||
$this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren
|
||||
|
||||
// Trägheit system
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Boiler spezifische Properties
|
||||
$this->RegisterPropertyInteger("BoilerLeistungTeillast", 3000);
|
||||
$this->RegisterPropertyInteger("BoilerLeistungVolllast", 6000);
|
||||
$this->RegisterPropertyInteger("Boilertemperatur", 0);
|
||||
|
||||
// Boiler spezifische Variablen
|
||||
$this->RegisterVariableInteger("Boilermintemp", "Boilermintemp", "", 45);
|
||||
$this->RegisterVariableInteger("Boilermaxtemp", "Boilermaxtemp", "", 60);
|
||||
$this->RegisterVariableInteger("Boilerlegiotemp", "Boilerlegiotemp", "", 65);
|
||||
$this->RegisterVariableInteger("LegioCounter", "LegioCounter", "", 0);
|
||||
|
||||
// Schaltkontakte
|
||||
$this->RegisterPropertyInteger("Kontakt_Teillast", 0);
|
||||
$this->RegisterPropertyInteger("Kontakt_Volllast", 0);
|
||||
|
||||
// Initialisieren
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
|
||||
public function ApplyChanges() {
|
||||
parent::ApplyChanges();
|
||||
}
|
||||
|
||||
// Aktionen verarbeiten
|
||||
public function RequestAction($Ident, $Value) {
|
||||
switch ($Ident) {
|
||||
case "SetCurrentPower":
|
||||
$this->SetCurrentPower($Value);
|
||||
break;
|
||||
case "GetCurrentData":
|
||||
return $this->GetCurrentData($Value);
|
||||
default:
|
||||
throw new Exception("Invalid Ident");
|
||||
}
|
||||
}
|
||||
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetCurrentPower(int $power) {
|
||||
// Schalte Kontakt Teillast und Vollast entsprechend der Power-Einstellung
|
||||
if ($power == $this->ReadPropertyInteger("BoilerLeistungVolllast")) {
|
||||
SetValue($this->ReadPropertyInteger("Kontakt_Volllast"), true);
|
||||
SetValue($this->ReadPropertyInteger("Kontakt_Teillast"), false);
|
||||
} elseif ($power == $this->ReadPropertyInteger("BoilerLeistungTeillast")) {
|
||||
SetValue($this->ReadPropertyInteger("Kontakt_Volllast"), false);
|
||||
SetValue($this->ReadPropertyInteger("Kontakt_Teillast"), true);
|
||||
} else {
|
||||
SetValue($this->ReadPropertyInteger("Kontakt_Volllast"), false);
|
||||
SetValue($this->ReadPropertyInteger("Kontakt_Teillast"), false);
|
||||
}
|
||||
|
||||
// Prüfe auf Änderung der Power im Vergleich zur letzten Einstellung
|
||||
$lastPower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||
if ($power != $lastPower) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $this->ReadPropertyInteger("IdleCounterMax"));
|
||||
}
|
||||
|
||||
// Setze die neue CurrentPower
|
||||
$this->SetValue("CurrentPower", $power);
|
||||
|
||||
// IdleCounter verarbeiten
|
||||
$this->ProcessIdleCounter();
|
||||
}
|
||||
|
||||
|
||||
// Methode zum Abrufen der aktuellen Daten
|
||||
public function GetCurrentData(bool $Peak) {
|
||||
|
||||
$LegioCounter = $this->GetValue("LegioCounter");
|
||||
|
||||
$boilerTemp = GetValue($this->ReadPropertyInteger("Boilertemperatur"));
|
||||
$minTemp = $this->GetValue("Boilermintemp");
|
||||
$maxTemp = $this->GetValue("Boilermaxtemp");
|
||||
$LegioTemp = $this->GetValue("Boilerlegiotemp");
|
||||
$teilLeistung = $this->ReadPropertyInteger("BoilerLeistungTeillast");
|
||||
$vollLeistung = $this->ReadPropertyInteger("BoilerLeistungVolllast");
|
||||
|
||||
$AktuelleVollast = GetValue($this->ReadPropertyInteger("Kontakt_Volllast"));
|
||||
$AktuelleTeillast = GetValue($this->ReadPropertyInteger("Kontakt_Teillast"));
|
||||
|
||||
if($boilerTemp>$LegioTemp){
|
||||
$LegioCounter = 0;
|
||||
IPS_LogMessage("im1", $LegioCounter);
|
||||
|
||||
}else{
|
||||
$LegioCounter = $LegioCounter + 1;
|
||||
IPS_LogMessage("im2", $LegioCounter);
|
||||
|
||||
}
|
||||
if($LegioCounter > 69120){
|
||||
$maxTemp = $LegioTemp;
|
||||
IPS_LogMessage("im3", $LegioCounter);
|
||||
|
||||
|
||||
}
|
||||
if(($LegioCounter>120960) && ($this->ist_nachts())){
|
||||
$minTemp = $LegioTemp;
|
||||
IPS_LogMessage("im4", $LegioCounter);
|
||||
|
||||
}
|
||||
|
||||
$this->SetValue("LegioCounter", $LegioCounter);
|
||||
|
||||
|
||||
if ($Peak) {
|
||||
if ($boilerTemp < $minTemp) {
|
||||
$this->SetValue("PowerSteps", json_encode([0, $teilLeistung, $vollLeistung]));
|
||||
|
||||
} elseif ($boilerTemp < ($minTemp + 5) && ($AktuelleVollast || $AktuelleTeillast)) {
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([0, $teilLeistung, $vollLeistung]));
|
||||
}
|
||||
else {
|
||||
$this->SetValue("PowerSteps", json_encode([0]));
|
||||
|
||||
}
|
||||
} else {
|
||||
if ($boilerTemp < $minTemp) {
|
||||
$this->SetValue("PowerSteps", json_encode([$vollLeistung]));
|
||||
|
||||
} elseif ($boilerTemp < ($minTemp + 5) && ($AktuelleVollast || $AktuelleTeillast)) {
|
||||
$this->SetValue("PowerSteps", json_encode([$vollLeistung]));
|
||||
|
||||
}
|
||||
elseif ($boilerTemp < ($maxTemp-5)) {
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([0, $teilLeistung, $vollLeistung]));
|
||||
}
|
||||
elseif ($boilerTemp < ($maxTemp) && ($AktuelleVollast || $AktuelleTeillast)) {
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([0, $teilLeistung, $vollLeistung]));
|
||||
}
|
||||
else {
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function ProcessIdleCounter() {
|
||||
// IdleCounter auslesen und verarbeiten
|
||||
$idleCounter = $this->GetValue("IdleCounter");
|
||||
if ($idleCounter > 0) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
||||
} else {
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
}
|
||||
|
||||
private function CheckIdle($power) {
|
||||
$lastpower = GetValue("CurrentPower");
|
||||
if ($lastpower != GetValue("CurrentPower")) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $this->ReadPropertyInteger("IdleCounterMax"));
|
||||
}
|
||||
// IdleCounter auslesen und verarbeiten
|
||||
$idleCounter = $this->GetValue("IdleCounter");
|
||||
if ($idleCounter > 0) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
||||
} else {
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function ist_nachts() {
|
||||
date_default_timezone_set('Europe/Berlin'); // Setze hier deine Zeitzone
|
||||
|
||||
$aktuelle_zeit = strtotime(date('H:i')); // Aktuelle Zeit in Stunden und Minuten umwandeln
|
||||
$start_nacht = strtotime('22:00'); // Startzeit der Nacht (22 Uhr)
|
||||
$ende_nacht = strtotime('07:00'); // Endzeit der Nacht (7 Uhr)
|
||||
|
||||
if ($aktuelle_zeit >= $start_nacht || $aktuelle_zeit < $ende_nacht) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
67
Ladestation_Universal/README.md
Normal file
67
Ladestation_Universal/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# 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);`
|
||||
30
Ladestation_Universal/form.json
Normal file
30
Ladestation_Universal/form.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "ValidationTextBox",
|
||||
"name": "IP_Adresse",
|
||||
"caption": "IP-Adresse Go-E",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "MinLeistung",
|
||||
"caption": "Mindestleistung Ladestation"
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "IdleCounterMax",
|
||||
"caption": "Zyklen zwischen zwei Leisutungsänderungen",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "MaxLeistung",
|
||||
"caption": "Maximlalleistung Ladestation"
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Aktuell wird nur Go-E ladestation zu testzwecken unterstützt!"
|
||||
}
|
||||
]
|
||||
}
|
||||
8
Ladestation_Universal/locale.json
Normal file
8
Ladestation_Universal/locale.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"translations": {
|
||||
"de": {
|
||||
"Translation 1": "Übersetzung 1",
|
||||
"Translation 2": "Übersetzung 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Ladestation_Universal/module.json
Normal file
12
Ladestation_Universal/module.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{C684C38F-8C0D-CCE0-4533-11769F314B2D}",
|
||||
"name": "Ladestation_Universal",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
349
Ladestation_Universal/module.php
Normal file
349
Ladestation_Universal/module.php
Normal file
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
|
||||
class Ladestation_Universal extends IPSModule {
|
||||
|
||||
public function Create() {
|
||||
parent::Create();
|
||||
|
||||
// Prioritäten
|
||||
$this->RegisterVariableInteger("LockPrio", "LockPrio");
|
||||
$this->RegisterVariableInteger("UserPrio", "UserPrio");
|
||||
|
||||
// Energiehandling
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0);
|
||||
$this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren
|
||||
|
||||
// Trägheit
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Properties registrieren
|
||||
$this->RegisterPropertyInteger("MinLeistung", 3600);
|
||||
$this->RegisterPropertyInteger("MaxLeistung", 11000);
|
||||
$this->RegisterPropertyString("IP_Adresse", "0.0.0.0");
|
||||
|
||||
$this->RegisterVariableBoolean("Ladebereit", "Ladebereit", "~Switch", 11);
|
||||
$this->RegisterVariableBoolean("Solarladen", "Solarladen", "~Switch", 11);
|
||||
$this->RegisterVariableInteger("Fahrzeugstatus", "Fahrzeugstatus", "", 0);
|
||||
|
||||
|
||||
|
||||
$this->RegisterVariableBoolean("Peak", "Peak", "", 0);
|
||||
|
||||
$this->RegisterVariableInteger("Ladestrom", "Ladestrom");
|
||||
$this->RegisterVariableInteger("Ladeleistung", "Ladeleistung");
|
||||
|
||||
// Initialisieren
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
|
||||
public function ApplyChanges() {
|
||||
parent::ApplyChanges();
|
||||
// Zusätzliche Anpassungen nach Bedarf
|
||||
}
|
||||
|
||||
// Aktionen verarbeiten
|
||||
public function RequestAction($Ident, $Value) {
|
||||
switch ($Ident) {
|
||||
case "SetCurrentPower":
|
||||
$this->SetCurrentPower($Value);
|
||||
break;
|
||||
case "GetCurrentData":
|
||||
$powerSteps = $this->GetCurrentData($Value);
|
||||
return $powerSteps;
|
||||
default:
|
||||
throw new Exception("Invalid Ident");
|
||||
}
|
||||
}
|
||||
|
||||
public function SetCurrentPower(int $power) {
|
||||
$internalPower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||
// Aktuelle Leistungsvorgabe setzen
|
||||
SetValue($this->GetIDForIdent("CurrentPower"), $power);
|
||||
if ($power != $internalPower) {
|
||||
// Setze die interne Leistungsvorgabe
|
||||
|
||||
// Idle für 4 Zyklen auf false setzen
|
||||
SetValue($this->GetIDForIdent("Idle"), false);
|
||||
SetValue($this->GetIDForIdent("IdleCounter"), $this->ReadPropertyInteger("IdleCounterMax"));
|
||||
} else {
|
||||
// IdleCallCounter herunterzählen, wenn power == interne Leistungsvorgabe
|
||||
$idleCounter = GetValue($this->GetIDForIdent("IdleCounter"));
|
||||
if ($idleCounter > 0) {
|
||||
$idleCounter--;
|
||||
SetValue($this->GetIDForIdent("IdleCounter"), $idleCounter);
|
||||
if ($idleCounter == 0) {
|
||||
SetValue($this->GetIDForIdent("Idle"), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Ladeleistung setzen
|
||||
$peak = GetValue($this->GetIDForIdent("Peak"));
|
||||
$solarladen = GetValue($this->GetIDForIdent("Solarladen"));
|
||||
$Ladebereit = GetValue($this->GetIDForIdent("Ladebereit"));
|
||||
if(!$Ladebereit){
|
||||
|
||||
$this->sendPowerToStation(0);
|
||||
SetValue($this->GetIDForIdent("Ladeleistung"), 0);
|
||||
SetValue($this->GetIDForIdent("Ladestrom"), 0);
|
||||
|
||||
}
|
||||
elseif (!$peak && !$solarladen) {
|
||||
// Wenn weder Peak noch Solarladen aktiv sind, setze Ladeleistung auf MaxLeistung
|
||||
SetValue($this->GetIDForIdent("Ladeleistung"), $this->ReadPropertyInteger("MaxLeistung"));
|
||||
SetValue($this->GetIDForIdent("Ladestrom"), $this->ReadPropertyInteger("MaxLeistung") / 400 / sqrt(3));
|
||||
$this->sendPowerToStation($this->ReadPropertyInteger("MaxLeistung"));
|
||||
|
||||
} else {
|
||||
// Ansonsten setze Ladeleistung auf die aktuelle Leistungsvorgabe (CurrentPower)
|
||||
SetValue($this->GetIDForIdent("Ladeleistung"), $power);
|
||||
SetValue($this->GetIDForIdent("Ladestrom"), $power / 400 / sqrt(3));
|
||||
$this->sendPowerToStation($power);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methode zum Abrufen der aktuellen Daten
|
||||
public function GetCurrentData(bool $Peak) {
|
||||
// Aktuelle Properties abrufen
|
||||
$ladebereit = GetValue($this->GetIDForIdent("Ladebereit"));
|
||||
$solarladen = GetValue($this->GetIDForIdent("Solarladen"));
|
||||
$minLeistung = $this->ReadPropertyInteger("MinLeistung");
|
||||
$maxLeistung = $this->ReadPropertyInteger("MaxLeistung");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
// Setze die URL
|
||||
curl_setopt($ch, CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=");
|
||||
|
||||
// Setze die Option, die Antwort als String zurückzugeben
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// Führe die Anfrage aus und speichere die Antwort
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Schließe cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Überprüfe, ob die Antwort nicht leer ist
|
||||
if ($response) {
|
||||
// Dekodiere die JSON-Antwort
|
||||
$data = json_decode($response, true);
|
||||
|
||||
// Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data['car'])) {
|
||||
// Speichere den Wert von "car" in der Variable $status
|
||||
SetValue($this->GetIDForIdent("Fahrzeugstatus"), $data['car']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Peak-Wert speichern
|
||||
$this->SetValue("Peak", $Peak);
|
||||
|
||||
// Array für die Powersteps initialisieren
|
||||
$powerSteps = [0];
|
||||
|
||||
if(GetValue($this->GetIDForIdent("Fahrzeugstatus"))!=1){
|
||||
// Konfiguration des powerSteps-Arrays basierend auf den Properties
|
||||
if (!$ladebereit) {
|
||||
$powerSteps = [0];
|
||||
|
||||
} elseif (!$Peak && !$solarladen) {
|
||||
|
||||
$powerSteps = [$maxLeistung];
|
||||
} elseif (!$Peak && $solarladen) {
|
||||
$powerSteps = array_merge($powerSteps, $this->getRangeLimits($minLeistung, $maxLeistung));
|
||||
|
||||
} elseif ($solarladen && $Peak) {
|
||||
$powerSteps = [0];
|
||||
|
||||
} else {
|
||||
$powerSteps += $this->getRangeLimits($minLeistung, $maxLeistung);
|
||||
|
||||
}
|
||||
}
|
||||
// PowerSteps in der RegisterVariable speichern
|
||||
SetValue($this->GetIDForIdent("PowerSteps"), json_encode($powerSteps));
|
||||
|
||||
// Rückgabe der Powersteps
|
||||
return $powerSteps;
|
||||
}
|
||||
|
||||
|
||||
public function sendPowerToStation($value) {
|
||||
// Base URL
|
||||
$baseUrl = "http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=";
|
||||
IPS_LogMessage("Ladestation", "Aufgerufene ip" . $baseUrl);
|
||||
$value = $this->convertPowerToCurrent($value);
|
||||
// Initialize a cURL session
|
||||
$ch = curl_init();
|
||||
|
||||
// If value is 0, make a single request
|
||||
if ($value == 0) {
|
||||
$url = $baseUrl . "alw=0";
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
// For value between 1 and 32, make two requests
|
||||
else if ($value >= 1 && $value <= 32) {
|
||||
// First request
|
||||
$url1 = $baseUrl . "alw=1";
|
||||
curl_setopt($ch, CURLOPT_URL, $url1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response1 = curl_exec($ch);
|
||||
|
||||
// Check for errors
|
||||
if (curl_errno($ch)) {
|
||||
curl_close($ch);
|
||||
return 'Error:' . curl_error($ch);
|
||||
}
|
||||
|
||||
// Second request
|
||||
$url2 = $baseUrl . "amp=$value";
|
||||
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||
$response2 = curl_exec($ch);
|
||||
|
||||
// Check for errors
|
||||
if (curl_errno($ch)) {
|
||||
curl_close($ch);
|
||||
return 'Error:' . curl_error($ch);
|
||||
}
|
||||
|
||||
// Close cURL session
|
||||
curl_close($ch);
|
||||
|
||||
// Return responses
|
||||
return [$response1, $response2];
|
||||
}
|
||||
|
||||
// If value is out of range
|
||||
else {
|
||||
return "Invalid value. Must be between 0 and 32.";
|
||||
}
|
||||
}
|
||||
|
||||
public function convertPowerToCurrent($value) {
|
||||
if ($value == 0) {
|
||||
return 0;
|
||||
} elseif ($value == 4150) {
|
||||
return 6;
|
||||
} elseif ($value == 4850) {
|
||||
return 7;
|
||||
} elseif ($value == 5550) {
|
||||
return 8;
|
||||
} elseif ($value == 6250) {
|
||||
return 9;
|
||||
} elseif ($value == 6950) {
|
||||
return 10;
|
||||
} elseif ($value == 7600) {
|
||||
return 11;
|
||||
} elseif ($value == 8300) {
|
||||
return 12;
|
||||
} elseif ($value == 9000) {
|
||||
return 13;
|
||||
} elseif ($value == 9700) {
|
||||
return 14;
|
||||
} elseif ($value == 10300) {
|
||||
return 15;
|
||||
} elseif ($value == 11000) {
|
||||
return 16;
|
||||
} elseif ($value == 11750) {
|
||||
return 17;
|
||||
} elseif ($value == 12450) {
|
||||
return 18;
|
||||
} elseif ($value == 13150) {
|
||||
return 19;
|
||||
} elseif ($value == 13850) {
|
||||
return 20;
|
||||
} elseif ($value == 14550) {
|
||||
return 21;
|
||||
} elseif ($value == 15250) {
|
||||
return 22;
|
||||
} elseif ($value == 15900) {
|
||||
return 23;
|
||||
} elseif ($value == 16600) {
|
||||
return 24;
|
||||
} elseif ($value == 17300) {
|
||||
return 25;
|
||||
} elseif ($value == 18000) {
|
||||
return 26;
|
||||
} elseif ($value == 18700) {
|
||||
return 27;
|
||||
} elseif ($value == 19400) {
|
||||
return 28;
|
||||
} elseif ($value == 20100) {
|
||||
return 29;
|
||||
} elseif ($value == 20800) {
|
||||
return 30;
|
||||
} elseif ($value == 21500) {
|
||||
return 31;
|
||||
} elseif ($value == 22000) {
|
||||
return 32;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getRangeLimits($min, $max) {
|
||||
$limits = [
|
||||
4150,
|
||||
4850,
|
||||
5550,
|
||||
6250,
|
||||
6950,
|
||||
7600,
|
||||
8300,
|
||||
9000,
|
||||
9700,
|
||||
10300,
|
||||
11000,
|
||||
11750,
|
||||
12450,
|
||||
13150,
|
||||
13850,
|
||||
14550,
|
||||
15250,
|
||||
15900,
|
||||
16600,
|
||||
17300,
|
||||
18000,
|
||||
18700,
|
||||
19400,
|
||||
20100,
|
||||
20800,
|
||||
21500,
|
||||
22000
|
||||
];
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($limits as $limit) {
|
||||
if ($limit >= $min && $limit <= $max) {
|
||||
$result[] = $limit;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
67
Manager/README.md
Normal file
67
Manager/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# 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);`
|
||||
46
Manager/form.json
Normal file
46
Manager/form.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Einstellungen Energiemanager"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Peakleistung",
|
||||
"caption": "Sollwertvorgabe für Peakshaving",
|
||||
"suffix": "Watt"
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Ueberschussleistung",
|
||||
"caption": "Sollwertvorgabe für Solarladen",
|
||||
"suffix": "Watt"
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Netzbezug",
|
||||
"caption": "Variable mit dem zu regelnden Netzbezug"
|
||||
},
|
||||
{
|
||||
"type": "List",
|
||||
"name": "EnergyUserList",
|
||||
"caption": "Verbraucher, die gemanagt werden sollen.",
|
||||
"add": true,
|
||||
"delete": true,
|
||||
"sortable": true,
|
||||
"columns": [
|
||||
{
|
||||
"caption": "Energieverbraucher",
|
||||
"name": "EnergyUser",
|
||||
"width": "auto",
|
||||
"add": 0,
|
||||
"edit": {
|
||||
"type": "SelectInstance",
|
||||
"filter": "EnergyUser"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
8
Manager/locale.json
Normal file
8
Manager/locale.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"translations": {
|
||||
"de": {
|
||||
"Translation 1": "Übersetzung 1",
|
||||
"Translation 2": "Übersetzung 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Manager/module.json
Normal file
12
Manager/module.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{F1F645F9-7F78-2843-2728-5D1708A4F835}",
|
||||
"name": "Manager",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
222
Manager/module.php
Normal file
222
Manager/module.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
class Manager extends IPSModule {
|
||||
|
||||
public function Create() {
|
||||
parent::Create();
|
||||
|
||||
// Systemvariablen registrieren
|
||||
$this->RegisterPropertyInteger("Peakleistung", 0);
|
||||
$this->RegisterPropertyInteger("Ueberschussleistung", 0);
|
||||
$this->RegisterPropertyInteger("Netzbezug", 0); // Initialisierung mit 0
|
||||
$this->RegisterPropertyString("EnergyUserList", "[]");
|
||||
|
||||
// Timer registrieren
|
||||
$this->RegisterTimer("Timer_DistributeEnergy", 5000, 'IPS_RequestAction(' . $this->InstanceID . ', "DistributeEnergy", "");');
|
||||
}
|
||||
|
||||
public function ApplyChanges() {
|
||||
parent::ApplyChanges();
|
||||
|
||||
// Zusätzliche Konfigurationslogik hier hinzufügen
|
||||
$energyUserList = $this->ReadPropertyString("EnergyUserList");
|
||||
IPS_LogMessage("Manager", "EnergyUserList: " . $energyUserList);
|
||||
}
|
||||
|
||||
public function RequestAction($Ident, $Value) {
|
||||
switch ($Ident) {
|
||||
case "DistributeEnergy":
|
||||
$this->DistributeEnergy();
|
||||
break;
|
||||
case "ApplyChanges":
|
||||
$this->ApplyChanges();
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid Ident");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function DistributeEnergy() {
|
||||
// Systemvariablen abrufen
|
||||
$Netzbezug = GetValue(($this->ReadPropertyInteger('Netzbezug')));
|
||||
$Peakleistung = $this->ReadPropertyInteger('Peakleistung');
|
||||
$Ueberschussleistung = $this->ReadPropertyInteger('Ueberschussleistung');
|
||||
IPS_LogMessage("Leistung", $Ueberschussleistung);
|
||||
IPS_LogMessage("Netzbezug", $Netzbezug);
|
||||
IPS_LogMessage("Peak", $Peakleistung);
|
||||
|
||||
// Fallunterscheidung
|
||||
if ($Netzbezug < ($Peakleistung - $Ueberschussleistung) / 2) {
|
||||
$remainingPower = (-1) * ((-1 * $Ueberschussleistung) + $Netzbezug);
|
||||
$getCurrentDataParam = false;
|
||||
} else {
|
||||
$remainingPower = ($Peakleistung - $Netzbezug);
|
||||
$getCurrentDataParam = true;
|
||||
}
|
||||
|
||||
// EnergyUserList auslesen und dekodieren
|
||||
$energyUserListJSON = $this->ReadPropertyString("EnergyUserList");
|
||||
$energyUserList = json_decode($energyUserListJSON, true);
|
||||
|
||||
if (empty($energyUserList)) {
|
||||
// Liste ist leer, daher nichts zu tun
|
||||
return;
|
||||
}
|
||||
|
||||
// Schleife, um IPS_RequestAction für alle Benutzer auszuführen
|
||||
foreach ($energyUserList as $user) {
|
||||
if (IPS_InstanceExists($user['EnergyUser'])) {
|
||||
IPS_RequestAction($user['EnergyUser'], 'GetCurrentData', $getCurrentDataParam);
|
||||
}
|
||||
}
|
||||
|
||||
$filteredEnergyUsers = [];
|
||||
$allIdle = true; // Variable zur Überprüfung, ob alle Benutzer Idle = true sind
|
||||
$totalCurrentPower = 0; // Variable zur Summierung der CurrentPower Werte
|
||||
|
||||
foreach ($energyUserList as $user) {
|
||||
if (!IPS_InstanceExists($user['EnergyUser'])) {
|
||||
IPS_LogMessage("Manager", "Instance does not exist: " . $user['EnergyUser']);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Werte direkt von der EnergyUser-Instanz abrufen
|
||||
$currentPower = GetValue(IPS_GetObjectIDByIdent('CurrentPower', $user['EnergyUser']));
|
||||
$usedEnergy = GetValue(IPS_GetObjectIDByIdent('UsedEnergy', $user['EnergyUser']));
|
||||
$userPrio = GetValue(IPS_GetObjectIDByIdent('UserPrio', $user['EnergyUser']));
|
||||
$lockPrio = GetValue(IPS_GetObjectIDByIdent('LockPrio', $user['EnergyUser']));
|
||||
$idle = GetValue(IPS_GetObjectIDByIdent('Idle', $user['EnergyUser']));
|
||||
$powerStepsJson = GetValue(IPS_GetObjectIDByIdent('PowerSteps', $user['EnergyUser']));
|
||||
$powerSteps = json_decode($powerStepsJson, true);
|
||||
IPS_LogMessage("Manager", "PowerSteps for EnergyUser {$user['EnergyUser']}: " . print_r($powerSteps, true));
|
||||
|
||||
// EnergyUser-Daten zum gefilterten Array hinzufügen
|
||||
$filteredEnergyUsers[] = [
|
||||
'EnergyUser' => $user['EnergyUser'],
|
||||
'InstanceID' => $user['EnergyUser'],
|
||||
'CurrentPower' => $currentPower,
|
||||
'UsedEnergy' => $usedEnergy,
|
||||
'UserPrio' => $userPrio,
|
||||
'LockPrio' => $lockPrio,
|
||||
'Idle' => $idle,
|
||||
'PowerSteps' => $powerSteps // PowerSteps direkt hier hinzufügen
|
||||
];
|
||||
|
||||
// Überprüfen, ob alle Benutzer Idle = true sind
|
||||
if (!$idle) {
|
||||
$allIdle = false;
|
||||
}
|
||||
|
||||
// Add the totalCurrentPower to the remainingPower
|
||||
$totalCurrentPower += $currentPower;
|
||||
}
|
||||
$remainingPower += $totalCurrentPower;
|
||||
|
||||
// Debug-Ausgabe der gefilterten EnergyUser-Instanzen
|
||||
IPS_LogMessage("Manager", "Filtered Energy Users: " . print_r($filteredEnergyUsers, true));
|
||||
IPS_LogMessage("Manager", "Remaining Power after adding CurrentPower: " . $remainingPower);
|
||||
|
||||
if (empty($filteredEnergyUsers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Wenn nicht alle Benutzer Idle = true sind, rufe SetCurrentPower mit CurrentPower Werten auf
|
||||
if (!$allIdle) {
|
||||
foreach ($filteredEnergyUsers as $user) {
|
||||
IPS_RequestAction($user['InstanceID'], 'SetCurrentPower', $user['CurrentPower']);
|
||||
IPS_LogMessage("Manager", "SetCurrentPower for instance {$user['InstanceID']} to {$user['CurrentPower']} (Idle = false)");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Sortiere die EnergyUser nach Priorität basierend auf dem Parameter
|
||||
usort($filteredEnergyUsers, function($a, $b) use ($getCurrentDataParam) {
|
||||
$primaryKey = $getCurrentDataParam ? 'LockPrio' : 'UserPrio';
|
||||
|
||||
if ($a[$primaryKey] == $b[$primaryKey]) {
|
||||
return $a['UsedEnergy'] <=> $b['UsedEnergy'];
|
||||
}
|
||||
|
||||
return $a[$primaryKey] <=> $b[$primaryKey];
|
||||
});
|
||||
|
||||
// Primärschlüssel für die Priorität basierend auf dem Parameter auswählen
|
||||
$priorityKey = $getCurrentDataParam ? 'LockPrio' : 'UserPrio';
|
||||
|
||||
// Schleife durch alle Prioritäten
|
||||
$priorities = array_unique(array_column($filteredEnergyUsers, $priorityKey));
|
||||
foreach ($priorities as $priority) {
|
||||
// EnergyUser mit gleicher Priorität sammeln
|
||||
$samePriorityUsers = array_filter($filteredEnergyUsers, function ($user) use ($priority, $priorityKey) {
|
||||
return $user[$priorityKey] == $priority;
|
||||
});
|
||||
|
||||
// Wenn keine EnergyUser mit gleicher Priorität vorhanden sind, überspringen
|
||||
if (empty($samePriorityUsers)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Array für die verteilte Energie pro User erstellen
|
||||
$userEnergyProv = array_fill_keys(array_column($samePriorityUsers, 'InstanceID'), 0); // Initialisierung für jeden Benutzer auf 0 setzen
|
||||
|
||||
// Alle Schritte der Benutzer in einem Array sammeln
|
||||
$allSteps = [];
|
||||
foreach ($samePriorityUsers as $user) {
|
||||
foreach ($user['PowerSteps'] as $step) {
|
||||
$allSteps[] = ['user' => $user['InstanceID'], 'step' => $step];
|
||||
}
|
||||
}
|
||||
|
||||
// Sortiere die Schritte nach Größe
|
||||
usort($allSteps, function($a, $b) {
|
||||
return $a['step'] <=> $b['step'];
|
||||
});
|
||||
IPS_LogMessage("Allesteps", "Alle Steps :" . print_r($allSteps, true));
|
||||
|
||||
// Iteriere durch alle Schritte
|
||||
foreach ($allSteps as $entry) {
|
||||
$user = $entry['user'];
|
||||
$powerstep = $entry['step'];
|
||||
|
||||
// Überprüfe, ob noch genügend verbleibende Energie für den nächsten Schritt vorhanden ist
|
||||
if ($remainingPower >= $powerstep - $userEnergyProv[$user]) {
|
||||
// Aktualisiere die verbleibende Energie und die bereitgestellte Energie für den Benutzer
|
||||
$remainingPower -= ($powerstep - $userEnergyProv[$user]);
|
||||
$userEnergyProv[$user] = $powerstep;
|
||||
} //else {
|
||||
// Wenn nicht genug Energie vorhanden ist, setze die verbleibende Energie
|
||||
// Test dieses break rauszunehmen ... break;
|
||||
//}
|
||||
}
|
||||
|
||||
// Energie für jeden EnergyUser verbrauchen und loggen
|
||||
foreach ($userEnergyProv as $userInstanceID => $energy) {
|
||||
|
||||
$weui = min(array_column(array_filter($allSteps, function($entry) use ($userInstanceID) {
|
||||
return $entry['user'] == $userInstanceID;
|
||||
}), 'step'));
|
||||
;
|
||||
IPS_LogMessage("Neuerlog", "aktuell ist energy $energy und powersteps min ist $weui und powersteps ist ");
|
||||
|
||||
$energy = max($energy, $weui); // Testzeile
|
||||
IPS_LogMessage("Neuerlog", "nun ist energy $energy ");
|
||||
|
||||
// Methode SetCurrentPower für jeden EnergyUser aufrufen
|
||||
if (IPS_InstanceExists($userInstanceID)) {
|
||||
IPS_RequestAction($userInstanceID, 'SetCurrentPower', $energy); // Annahme: SetCurrentPower wird über eine Aktionsanfrage ausgeführt
|
||||
IPS_LogMessage("Manager", "SetCurrentPower for instance $userInstanceID to $energy");
|
||||
}
|
||||
}
|
||||
} // Debug-Ausgabe von allSteps und userEnergyProv
|
||||
IPS_LogMessage("Manager", "Final allSteps: " . print_r($allSteps, true));
|
||||
IPS_LogMessage("Manager", "Final userEnergyProv: " . print_r($userEnergyProv, true));
|
||||
|
||||
// Debug-Ausgabe des Endzustands
|
||||
foreach ($filteredEnergyUsers as $user) {
|
||||
IPS_LogMessage("Manager", "Final state for instance {$user['InstanceID']}: CurrentPower = {$user['CurrentPower']}, UsedEnergy = {$user['UsedEnergy']}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
67
Verbraucher_1_Stufig/README.md
Normal file
67
Verbraucher_1_Stufig/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# 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);`
|
||||
34
Verbraucher_1_Stufig/form.json
Normal file
34
Verbraucher_1_Stufig/form.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Einstellungen für einstufigen Verbruacher Ein-Aus"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "IdleCounterMax",
|
||||
"caption": "Zyklen zwischen zwei Leisutungsänderungen",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Mindesttlaufzeit",
|
||||
"caption": "Mindestlaufzeit des Verbruachers wärend eines Tages",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "BoilerLeistung",
|
||||
"caption": "Leistung des Verbrauchers",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Schaltkontakt1",
|
||||
"caption": "Zu schaltenden Kontakt",
|
||||
"test": true
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
8
Verbraucher_1_Stufig/locale.json
Normal file
8
Verbraucher_1_Stufig/locale.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"translations": {
|
||||
"de": {
|
||||
"Translation 1": "Übersetzung 1",
|
||||
"Translation 2": "Übersetzung 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Verbraucher_1_Stufig/module.json
Normal file
12
Verbraucher_1_Stufig/module.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{5A156BE6-30FE-55AC-A832-7F80BF043C8C}",
|
||||
"name": "Verbraucher_1_Stufig",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
162
Verbraucher_1_Stufig/module.php
Normal file
162
Verbraucher_1_Stufig/module.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
class Verbraucher_1_Stufig extends IPSModule {
|
||||
|
||||
public function Create() {
|
||||
parent::Create();
|
||||
|
||||
// Prioritäten
|
||||
$this->RegisterVariableInteger("LockPrio", "LockPrio");
|
||||
$this->RegisterVariableInteger("UserPrio", "UserPrio");
|
||||
|
||||
// Energiehandling
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableBoolean("IstNacht", "IstNacht", "", 0);
|
||||
$this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0);
|
||||
$this->RegisterVariableInteger("DailyOnTime", "DailyOnTime", "", 0);
|
||||
$this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren
|
||||
|
||||
// Trägheit
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 4);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
|
||||
$this->RegisterPropertyInteger("BoilerLeistung", 6000); // Standardwert für Volllast
|
||||
$this->RegisterPropertyInteger("Mindesttlaufzeit", 4); // Standardwert für Volllast
|
||||
$this->RegisterPropertyInteger("Schaltkontakt1", 0);
|
||||
|
||||
//Initialisieren
|
||||
$this->SetValue("Idle", true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function ApplyChanges() {
|
||||
parent::ApplyChanges();
|
||||
}
|
||||
|
||||
// Aktionen verarbeiten
|
||||
public function RequestAction($Ident, $Value) {
|
||||
switch ($Ident) {
|
||||
case "SetCurrentPower":
|
||||
$this->SetCurrentPower($Value);
|
||||
break;
|
||||
case "GetCurrentData":
|
||||
return $this->GetCurrentData($Value);
|
||||
default:
|
||||
throw new Exception("Invalid Ident");
|
||||
}
|
||||
}
|
||||
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetCurrentPower(float $power) {
|
||||
|
||||
$this->CheckIdle($power);
|
||||
$this->SetValue("CurrentPower", $power);
|
||||
$boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung");
|
||||
$schaltkontaktID = $this->ReadPropertyInteger("Schaltkontakt1");
|
||||
|
||||
if ($power == $boilerLeistung) {
|
||||
$schaltkontaktStatus = true;
|
||||
} elseif ($power == 0) {
|
||||
$schaltkontaktStatus = false;
|
||||
} else {
|
||||
// Keine Änderung, wenn power nicht 0 oder boilerLeistung entspricht
|
||||
return;
|
||||
}
|
||||
|
||||
$currentStatus = GetValue($this->ReadPropertyInteger("Schaltkontakt1"));
|
||||
|
||||
// Schaltkontaktstatus ändern
|
||||
SetValue($this->ReadPropertyInteger("Schaltkontakt1"), $schaltkontaktStatus);
|
||||
|
||||
if($schaltkontaktStatus){
|
||||
$this->SetValue("DailyOnTime", $this->GetValue("DailyOnTime")+1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Methode zum Abrufen der aktuellen Daten
|
||||
public function GetCurrentData(bool $Peak) {
|
||||
|
||||
$IstNacht = $this->GetValue("IstNacht");
|
||||
$NeuesIstNacht = $this->ist_nachts();
|
||||
|
||||
if($IstNacht==true && $NeuesIstNacht==false){
|
||||
|
||||
$this->SetValue("DailyOnTime", 0);
|
||||
|
||||
}
|
||||
|
||||
$this->SetValue("IstNacht", $NeuesIstNacht);
|
||||
|
||||
$DailyOnTime = $this->GetValue("DailyOnTime");
|
||||
$Mindestlaufzeit = $this->ReadPropertyInteger("Mindesttlaufzeit")*60*12;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($NeuesIstNacht && ($DailyOnTime<$Mindestlaufzeit)){
|
||||
|
||||
if($Peak){
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung")]));
|
||||
|
||||
}else{
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([$this->ReadPropertyInteger("BoilerLeistung")]));
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
if($Peak){
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([0]));
|
||||
|
||||
}else{
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung")]));
|
||||
|
||||
}}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function CheckIdle($power){
|
||||
|
||||
$lastpower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||
if($lastpower != $power){
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $this->ReadPropertyInteger("IdleCounterMax"));
|
||||
}
|
||||
// IdleCounter auslesen und verarbeiten
|
||||
$idleCounter = $this->GetValue("IdleCounter");
|
||||
if ($idleCounter > 0) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
||||
} else {
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
}
|
||||
|
||||
private function ist_nachts() {
|
||||
date_default_timezone_set('Europe/Berlin'); // Setze hier deine Zeitzone
|
||||
|
||||
$aktuelle_zeit = strtotime(date('H:i')); // Aktuelle Zeit in Stunden und Minuten umwandeln
|
||||
$start_nacht = strtotime('22:00'); // Startzeit der Nacht (22 Uhr)
|
||||
$ende_nacht = strtotime('07:00'); // Endzeit der Nacht (7 Uhr)
|
||||
|
||||
if ($aktuelle_zeit >= $start_nacht || $aktuelle_zeit < $ende_nacht) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
library.json
Normal file
12
library.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{89CAF37C-8E6E-5312-8195-6DA8AB7E5E70}",
|
||||
"name": "Manager",
|
||||
"author": "Daniel Haefliger",
|
||||
"url": "https://git.belevo.ch/dh/Modul_Test_Symcon",
|
||||
"compatibility": {
|
||||
"version": "7.1"
|
||||
},
|
||||
"version": "0.1",
|
||||
"build": 0,
|
||||
"date": 0
|
||||
}
|
||||
Reference in New Issue
Block a user