From 2c24e098d065728837833b131d1827b81f0646a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fliger?= Date: Fri, 7 Mar 2025 11:55:20 +0100 Subject: [PATCH] =?UTF-8?q?=C3=A4nderungen=20am=20Batteriemodul?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Batterie/module.php | 84 +++++++++++++++++++++++++++++++++++++---- HauptManager/module.php | 1 - library.json | 2 +- 3 files changed, 78 insertions(+), 9 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index ca53cd2..797eb9b 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -28,8 +28,10 @@ class Batterie extends IPSModule $this->RegisterVariableInteger("PV_Prio", "PV_Prio"); $this->RegisterVariableInteger("Power", "Power"); $this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving"); - $this->RegisterVariableBoolean("Hysterese", "Hysterese","",0); - $this->RegisterVariableBoolean("Hysterese_Netz", "Hysterese_Netz","",0); + //$this->RegisterVariableBoolean("Hysterese", "Hysterese","",0); + //$this->RegisterVariableBoolean("Hysterese_Netz", "Hysterese_Netz","",0); + + $this->RegisterVariableBoolean("Hysterese", "Hysterese","",false); @@ -151,15 +153,84 @@ public function RequestAction($Ident, $Value) public function GetCurrentData(bool $Peak) { + + if ($this->ReadPropertyInteger("Batteriemanagement") == 1) { + $dummy_array[] = 0; + return $this->SetValue("PowerSteps", json_encode($dummy_array)); + } + + $netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug")); + if (abs($netzbezug) > $maxleistung) { + $netzbezug = $maxleistung * (-1); + } + $array_powersteps = $this->GeneratePowerSteps(); $aufdasnachladen = $this->ReadPropertyInteger("AufdasNachladen"); $minimumentladen = $this->ReadPropertyInteger("MinimumEntladen"); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); $dummy_array = []; - $inhystere = $this->GetValue("Hysterese"); - $inhystere_netz = $this->GetValue("Hysterese_Netz"); + $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand"); + + if($batterieladezustand>(5+$aufdasnachladen)){ + + $this->SetValue("Hysterese", false); + + }elseif($batterieladezustand<$aufdasnachladen){ + $this->SetValue("Hysterese", true); + } + + $hyst = $this->GetValue("Hysterese"); + + if($Peak){ + + if($batterieladezustand>=$aufdasnachladen && $hyst==false){ + + $dummy_array[] = $netzbezug; + $this->SetValue("PowerSteps", json_encode($dummy_array)); + + }else if($batterieladezustand>$minimumentladen){ + + $this->SetValue("PowerSteps", json_encode($array_powersteps)); + } + else{ + + $filtered_powersteps = array_filter($array_powersteps, function ($value) { + return $value >= 0; + }); + $this->SetValue("PowerSteps", json_encode(array_values($filtered_powersteps))); + } + + } + + else{ + + if($batterieladezustand>99){ + + $filtered_powersteps_entladen = array_filter($array_powersteps, function ($value) { + return $value <= 0; + }); + $this->SetValue("PowerSteps", json_encode($filtered_powersteps_entladen)); + + }else if($batterieladezustand>=$aufdasnachladen && $hyst==false){ + + $this->SetValue("PowerSteps", json_encode($array_powersteps)); + + }else{ + + $dummy_array[] = $this->ReadPropertyInteger("MaxNachladen"); + $this->SetValue("PowerSteps", json_encode($dummy_array)); + + } + + } + + + + + // $inhystere = $this->GetValue("Hysterese"); + // $inhystere_netz = $this->GetValue("Hysterese_Netz"); - $batterieManagement = $this->ReadPropertyInteger("Batteriemanagement"); + /*$batterieManagement = $this->ReadPropertyInteger("Batteriemanagement"); if ($batterieManagement == 1) { $dummy_array[] = 0; return $this->SetValue("PowerSteps", json_encode($dummy_array)); @@ -172,7 +243,6 @@ public function RequestAction($Ident, $Value) IPS_LogMessage("Batterie", "Fehler: Ungültige Batterieladezustand-ID."); return; } - if ($Peak) { if ($batterieladezustand >= 5 + $aufdasnachladen) { $this->SetValue("Hysterese", false); @@ -268,7 +338,7 @@ public function RequestAction($Ident, $Value) $this->SetValue("PowerSteps", json_encode($filtered_powersteps_entladen)); IPS_LogMessage("Batterie", ": Solar über 100%" ); } - } + }*/ } diff --git a/HauptManager/module.php b/HauptManager/module.php index 1453195..027a91e 100644 --- a/HauptManager/module.php +++ b/HauptManager/module.php @@ -50,7 +50,6 @@ class HauptManager extends IPSModule $decodedUser = json_decode(GetValue($user["User_Up"]), true); - if (isset($decodedUser["Timestamp"]) && (($currentTime - $decodedUser["Timestamp"])) < 30) { foreach ($decodedUser["Users"] as $subuser) { diff --git a/library.json b/library.json index 4556480..d07f958 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "1.235", + "version": "1.236", "build": 0, "date": 0 } \ No newline at end of file