diff --git a/Batterie/form.json b/Batterie/form.json index 45af52e..4d7050d 100644 --- a/Batterie/form.json +++ b/Batterie/form.json @@ -29,18 +29,6 @@ "caption": "Minimum des Batterieladezustand", "suffix": "" }, - { - "type": "SelectVariable", - "name": "Entladestrom", - "caption": "Entladestrom", - "test": true - }, - { - "type": "SelectVariable", - "name": "Ladestrom", - "caption": "Ladestrom", - "test": true - }, { "type": "SelectVariable", "name": "Batterieladezustand", diff --git a/Batterie/module.php b/Batterie/module.php index f79d789..090fe3c 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -12,18 +12,21 @@ class Batterie extends IPSModule $this->RegisterPropertyInteger("AufdasNachladen",0); $this->RegisterPropertyInteger("MinimumEntladen",0); $this->RegisterPropertyInteger("Batterieladezustand",0); - $this->RegisterPropertyInteger("Ladestrom", 0); - $this->RegisterPropertyInteger("Entladestrom", 0); + // Variabeln für Kommunkation mit Manager - $this->RegisterVariableProfile("Batterie.Leistung", 1, "W"); - $this->RegisterVariableProfile("Batterie.Strom", 1, "A"); - $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "Batterie.Leistung", 0); + $this->RegisterVariableFloat("Ladestrom", "Ladestrom", "", 0); + $this->RegisterVariableFloat("Entladestrom", "Entladestrom", "", 0); + $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); $this->RegisterVariableBoolean("Idle", "Idle", "", 0); $this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio"); - $this->RegisterVariableInteger("PV_Prio", "PV_Prio"); - $this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "Batterie.Leistung", 0); + $this->RegisterVariableInteger("PV_Prio", "PV_Prio"); + $this->RegisterVariableInteger("Power", "Power"); + $this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving"); + + + $this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0); // Hilfsvariabeln für Idle zustand $this->RegisterPropertyInteger("IdleCounterMax", 2); @@ -32,6 +35,10 @@ class Batterie extends IPSModule // Initialisiere Idle $this->SetValue("Idle", true); + + $this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");'); + + } public function ApplyChanges() @@ -55,35 +62,39 @@ class Batterie extends IPSModule return $array_powersteps; } -private function RegisterVariableProfile(string $name, int $type, string $suffix) + + +public function RequestAction($Ident, $Value) { - if (!IPS_VariableProfileExists($name)) { - IPS_CreateVariableProfile($name, $type); - IPS_SetVariableProfileText($name, "", $suffix); + switch ($Ident) { + + case "SetAktuelle_Leistung": + $this->SetValue("Power", (int)$Value); + break; + + case "GetCurrentData": + $this->SetValue("Is_Peak_Shaving", (bool)$Value); + break; + + + case "Do_UserCalc": + + $this->SetAktuelle_Leistung($this->GetValue("Power")); + $this->GetCurrentData($this->GetValue("Is_Peak_Shaving")); + break; + + default: + throw new Exception("Invalid Ident"); } } - public function RequestAction($Ident, $Value) - { - - switch ($Ident) { - case "SetAktuelle_Leistung": - $this->SetAktuelle_Leistung($Value); - break; - case "GetCurrentData": - return $this->GetCurrentData($Value); - default: - throw new Exception("Invalid Ident"); - } - } - public function SetAktuelle_Leistung(int $power) { $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand"); // Als Property gelesen $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); // Als Property gelesen $spannung = $this->ReadPropertyInteger("Batteriespannung"); // Spannung ebenfalls als Property - $ladestrom = $this->ReadPropertyInteger("Ladestrom"); - $entladestrom = $this->ReadPropertyInteger("Entladestrom"); + $ladestrom = GetValue($this->GetIDForIdent("Ladestrom")); + $entladestrom = GetValue($this->GetIDForIdent("Entladestrom")); IPS_LogMessage("Batterie", "power: " . $power); diff --git a/Boiler_2_Stufig_Mit_Fueler/module.php b/Boiler_2_Stufig_Mit_Fueler/module.php index 8e6f7f0..8272664 100644 --- a/Boiler_2_Stufig_Mit_Fueler/module.php +++ b/Boiler_2_Stufig_Mit_Fueler/module.php @@ -15,15 +15,15 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule $this->RegisterPropertyInteger("Kontakt_Volllast", 0); $this->RegisterPropertyBoolean("Boilertemperatur_glätten", false); - - // Boiler spezifische Variablen + $this->RegisterVariableInteger("Mindesttemperatur","Mindesttemperatur","",45); $this->RegisterVariableInteger("Maximaltemperatur","Maximaltemperatur","",60); $this->RegisterVariableInteger("Legionellentemperatur","Legionellentemperatur","",65); $this->RegisterVariableInteger("LegioCounter", "LegioCounter", "", 0); + //$this->RegisterVariableInteger("Boilertemperatur", "Boilertemperatur", "", 0); $this->RegisterVariableInteger("Boilertemperatur", "Boilertemperatur", "", 0); - + // Variabeln für Kommunkation mit Manager $this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio"); @@ -32,6 +32,8 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); + $this->RegisterVariableInteger("Power", "Power"); + $this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving"); // Hilfsvariabeln für Idle zustand $this->RegisterPropertyInteger("IdleCounterMax", 2); @@ -40,30 +42,37 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule // Initialisiere Idle $this->SetValue("Idle", true); + + $this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");'); + } public function ApplyChanges() { parent::ApplyChanges(); + + } public function RequestAction($Ident, $Value) { - - switch ($Ident) { case "SetAktuelle_Leistung": - - $this->SetAktuelle_Leistung($Value); + $this->SetValue("Power", (int)$Value); break; case "GetCurrentData": - - $result = $this->GetCurrentData($Value); - return $result; - + $this->SetValue("Is_Peak_Shaving", (bool)$Value); + break; + + case "Do_UserCalc": + + $this->SetAktuelle_Leistung($this->GetValue("Power")); + $this->GetCurrentData($this->GetValue("Is_Peak_Shaving")); + break; + default: throw new Exception("Invalid Ident"); } @@ -112,35 +121,39 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule $boilertemperatur_glätten = $this->ReadPropertyBoolean("Boilertemperatur_glätten"); if ($boilertemperatur_glätten) { + // Wenn Glättung aktiviert ist, führe das Glätten durch $boilerFuehlerPT1ID = $this->ReadPropertyInteger("Boilerfuehler_PT1"); + if (IPS_VariableExists($boilerFuehlerPT1ID)) { $boilerPT1 = GetValue($boilerFuehlerPT1ID); } else { - $boilerPT1 = 0.0; + $boilerPT1 = 0.0; // Standardwert } - $boilerTemp_test = $this->GetIDForIdent("Boilertemperatur"); - if (IPS_VariableExists($boilerTemp_test)) { - $boilerTemp_test = $this->GetValue("Boilertemperatur"); + + $boilerTempID = $this->GetIDForIdent("Boilertemperatur"); + if (IPS_VariableExists($boilerTempID)) { + $boilerTemp = $this->GetValue("Boilertemperatur"); } else { - $boilerTemp_test = 0.0; + $boilerTemp = 0.0; // Standardwert } - $boilerPT1 = GetValue($boilerFuehlerPT1ID); - $boilerTemp_test = $this->GetValue("Boilertemperatur"); + + // PT $time_constant= $this->ReadPropertyInteger("ZeitKonstante"); - $delta_t = 30; + $delta_t = 30; // Zeitdifferenz zwischen den Messungen (30 Sekunden) $alpha = $delta_t / ($time_constant + $delta_t); - $newBoilerTemp = $boilerTemp_test + $alpha * ($boilerPT1 - $boilerTemp_test); + $newBoilerTemp = $boilerTemp + $alpha * ($boilerPT1 - $boilerTemp); $this->SetValue("Boilertemperatur", $newBoilerTemp); - } else { - + // Wenn Glättung nicht aktiviert ist, setze die Boilertemperatur direkt auf den Wert des Boilerfühlers $boilerFuehlerPT1ID = $this->ReadPropertyInteger("Boilerfuehler_PT1"); + if (IPS_VariableExists($boilerFuehlerPT1ID)) { $boilerPT1 = GetValue($boilerFuehlerPT1ID); } else { - $boilerPT1 = 0.0; + $boilerPT1 = 0.0; // Standardwert } - $boilerPT1 = GetValue($boilerFuehlerPT1ID); + + // Setze Boilertemperatur direkt auf den Wert des Boilerfühlers $this->SetValue("Boilertemperatur", $boilerPT1); } @@ -172,6 +185,9 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule if ($LegioCounter > 120960 && $this->ist_nachts()) { $minTemp = $LegioTemp; } + if ($LegioCounter > 138240) { // Timeout für Legio wenn temperatur nicht erreicht werden kann, setze legionellenfunktion zurück + $LegioCounter = 0; + } $this->SetValue("LegioCounter", $LegioCounter); diff --git a/Ladestation_Universal/module.php b/Ladestation_Universal/module.php index 2f1edb3..47658bd 100644 --- a/Ladestation_Universal/module.php +++ b/Ladestation_Universal/module.php @@ -36,6 +36,8 @@ class Ladestation_Universal extends IPSModule $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); + $this->RegisterVariableInteger("Power", "Power"); + $this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving"); // Hilfsvariabeln für Idle zustand $this->RegisterPropertyInteger("IdleCounterMax", 2); @@ -44,6 +46,9 @@ class Ladestation_Universal extends IPSModule // Initialisiere Idle $this->SetValue("Idle", true); + + $this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");'); + } public function ApplyChanges() @@ -52,16 +57,24 @@ class Ladestation_Universal extends IPSModule // Zusätzliche Anpassungen nach Bedarf } - // Aktionen verarbeiten public function RequestAction($Ident, $Value) { switch ($Ident) { + case "SetAktuelle_Leistung": - $this->SetAktuelle_Leistung($Value); + $this->SetValue("Power", (int)$Value); break; + case "GetCurrentData": - $powerSteps = $this->GetCurrentData($Value); - return $powerSteps; + $this->SetValue("Is_Peak_Shaving", (bool)$Value); + break; + + case "Do_UserCalc": + + $this->SetAktuelle_Leistung($this->GetValue("Power")); + $this->GetCurrentData($this->GetValue("Is_Peak_Shaving")); + break; + default: throw new Exception("Invalid Ident"); } diff --git a/Manager/module.php b/Manager/module.php index 053d582..6da2dc3 100644 --- a/Manager/module.php +++ b/Manager/module.php @@ -254,6 +254,11 @@ class Manager extends IPSModule } } } + + + + + } } ?> diff --git a/Verbraucher_1_Stufig/module.php b/Verbraucher_1_Stufig/module.php index 586c6c8..e4313cc 100644 --- a/Verbraucher_1_Stufig/module.php +++ b/Verbraucher_1_Stufig/module.php @@ -29,6 +29,8 @@ class Verbraucher_1_Stufig extends IPSModule $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); + $this->RegisterVariableInteger("Power", "Power"); + $this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving"); // Hilfsvariabeln für Idle zustand $this->RegisterPropertyInteger("IdleCounterMax", 2); @@ -37,6 +39,9 @@ class Verbraucher_1_Stufig extends IPSModule // Initialisiere Idle $this->SetValue("Idle", true); + + $this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");'); + } public function ApplyChanges() @@ -44,24 +49,34 @@ class Verbraucher_1_Stufig extends IPSModule parent::ApplyChanges(); } - // Aktionen verarbeiten public function RequestAction($Ident, $Value) { switch ($Ident) { + case "SetAktuelle_Leistung": - $this->SetAktuelle_Leistung($Value); + $this->SetValue("Power", (int)$Value); break; + case "GetCurrentData": - return $this->GetCurrentData($Value); + $this->SetValue("Is_Peak_Shaving", (bool)$Value); break; + case "ResetPowerSteps": $this->ResetPowerSteps($Value); break; + + case "Do_UserCalc": + $this->SetAktuelle_Leistung($this->GetValue("Power")); + $this->GetCurrentData($this->GetValue("Is_Peak_Shaving")); + break; + default: throw new Exception("Invalid Ident"); } } + + // Methode zum Setzen der PowerSteps und Timer starten public function SetTimerOn() { diff --git a/WP_Steuerung/module.php b/WP_Steuerung/module.php index d69e53a..1983100 100644 --- a/WP_Steuerung/module.php +++ b/WP_Steuerung/module.php @@ -34,6 +34,8 @@ class WP_Steuerung extends IPSModule $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); + $this->RegisterVariableInteger("Power", "Power"); + $this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving"); // Hilfsvariabeln für Idle zustand $this->RegisterPropertyInteger("IdleCounterMax", 2); @@ -42,6 +44,9 @@ class WP_Steuerung extends IPSModule // Initialisiere Idle $this->SetValue("Idle", true); + + $this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");'); + } public function ApplyChanges() @@ -49,24 +54,34 @@ class WP_Steuerung extends IPSModule parent::ApplyChanges(); } - // Aktionen verarbeiten + public function RequestAction($Ident, $Value) { switch ($Ident) { + case "SetAktuelle_Leistung": - $this->SetAktuelle_Leistung($Value); + $this->SetValue("Power", (int)$Value); break; + case "GetCurrentData": - return $this->GetCurrentData($Value); + $this->SetValue("Is_Peak_Shaving", (bool)$Value); break; + case "ResetPowerSteps": $this->ResetPowerSteps($Value); break; + + case "Do_UserCalc": + $this->SetAktuelle_Leistung($this->GetValue("Power")); + $this->GetCurrentData($this->GetValue("Is_Peak_Shaving")); + break; + default: throw new Exception("Invalid Ident"); } } + // Methode zum Setzen des aktuellen Stromverbrauchs public function SetAktuelle_Leistung(float $power) { diff --git a/library.json b/library.json index 325ae2e..70b43eb 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.277", + "version": "1.0", "build": 0, "date": 0