From ff59cbaff634ae4c1c7194c971895e10ebc03bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fliger?= Date: Tue, 12 Nov 2024 10:54:16 +0100 Subject: [PATCH] =?UTF-8?q?=C3=A4nderungen=20an=20WP-Sperre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WP_Steuerung/module.php | 86 ++++++++++++++++------------------------- library.json | 2 +- 2 files changed, 34 insertions(+), 54 deletions(-) diff --git a/WP_Steuerung/module.php b/WP_Steuerung/module.php index 995a07e..5f05ad0 100644 --- a/WP_Steuerung/module.php +++ b/WP_Steuerung/module.php @@ -12,6 +12,7 @@ class WP_Steuerung extends IPSModule { // Energiehandling $this->RegisterVariableBoolean("Idle", "Idle", "", true); $this->RegisterVariableInteger("CurrentPower", "CurrentPower", "", 0); + $this->RegisterVariableBoolean("Sperrzeit", "Sperrzeit", "", false); $this->RegisterVariableFloat("UsedEnergy", "UsedEnergy", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); // PowerSteps-Variable registrieren @@ -80,20 +81,34 @@ class WP_Steuerung extends IPSModule { $entsperrzeit = GetValue($this->ReadPropertyInteger("Referenzzeit"))%86400; $aktuellezeit = time()%86400; - $its_lock_time = false; - if($aktuellezeit > $sperrzeit && $aktuellezeit < $entsperrzeit){ - $its_lock_time = true; - } - $timestamp = time(); - IPS_LogMessage("sperrzeit", $sperrzeit); - IPS_LogMessage("entsperrzeit", $entsperrzeit); - IPS_LogMessage("aktuellezeit", $aktuellezeit); - IPS_LogMessage("itslocktime", $its_lock_time); - IPS_LogMessage("sperrzeitabs", $sperrzei_abs); - $this->CheckIdle($power); - if($this->GetValue("CurrentPower")!=$power){ + $its_lock_time = $this->GetValue("Sperrzeit"); + if($aktuellezeit > $sperrzeit && $aktuellezeit < $entsperrzeit){ + $this->SetValue("Sperrzeit", true); + + } + else{ + $this->SetValue("Sperrzeit", false); + } + + $newlocktime = $this->GetValue("Sperrzeit"); + + + if($newlocktime == true && $its_lock_time==false && $this->GetValue("WP_Laufzeit_Zahler")>240){ + $this->SetValue("WP_Laufzeit_Zahler", 0); + SetValue($this->ReadPropertyInteger("Sperrkontakt"), true); + + } + + elseif($newlocktime == false && $its_lock_time == true && $this->GetValue("WP_Laufzeit_Zahler")>240){ + $this->SetValue("WP_Laufzeit_Zahler", 0); + SetValue($this->ReadPropertyInteger("Sperrkontakt"), false); + + } + + + elseif($this->GetValue("CurrentPower")!=$power){ $this->SetValue("WP_Laufzeit_Zahler", 0); $LastPeak = $this->GetValue("LetzterPeakwert"); @@ -112,11 +127,7 @@ class WP_Steuerung extends IPSModule { $this->SetValue("Zustand_WP", 1); $this->SetValue("CurrentPower", $this->ReadPropertyInteger("WP_Leistung")); - if($its_lock_time){ - $this->SetValue("Zustand_WP", 2); - $this->SetValue("CurrentPower", $this->ReadPropertyInteger("WP_Leistung")); - - } + } elseif($LastPeak && $power == 0){ $this->SetValue("Zustand_WP", 2); $this->SetValue("CurrentPower", 0); @@ -132,16 +143,6 @@ class WP_Steuerung extends IPSModule { elseif($LastPeak == false && $power == 0){ $this->SetValue("Zustand_WP", 1); $this->SetValue("CurrentPower", 0); - IPS_LogMessage("here", $aktuellezeit); - - - if($its_lock_time){ - $this->SetValue("Zustand_WP", 2); - $this->SetValue("CurrentPower", 0); - IPS_LogMessage("herrre", $aktuellezeit); - - - } } @@ -151,11 +152,7 @@ class WP_Steuerung extends IPSModule { $this->SetValue("Zustand_WP", 1); $this->SetValue("CurrentPower", $this->ReadPropertyInteger("WP_Leistung")); - if($its_lock_time){ - $this->SetValue("Zustand_WP", 2); - $this->SetValue("CurrentPower", $this->ReadPropertyInteger("WP_Leistung")); - - } + } elseif($LastPeak && $power == 0){ $this->SetValue("Zustand_WP", 2); $this->SetValue("CurrentPower", 0); @@ -171,16 +168,8 @@ class WP_Steuerung extends IPSModule { elseif($LastPeak == false && $power == 0){ $this->SetValue("Zustand_WP", 1); $this->SetValue("CurrentPower", 0); - IPS_LogMessage("herrre", $aktuellezeit); - if($its_lock_time){ - $this->SetValue("Zustand_WP", 2); - $this->SetValue("CurrentPower", 0); - IPS_LogMessage("here", $aktuellezeit); - - } - } }elseif($state == 3) // Erhöht @@ -189,12 +178,7 @@ class WP_Steuerung extends IPSModule { if($LastPeak && $power == ($this->ReadPropertyInteger("WP_Leistung"))) { $this->SetValue("Zustand_WP", 1); $this->SetValue("CurrentPower", $this->ReadPropertyInteger("WP_Leistung")); - - if($its_lock_time){ - $this->SetValue("Zustand_WP", 2); - $this->SetValue("CurrentPower", $this->ReadPropertyInteger("WP_Leistung")); - - } + } elseif($LastPeak && $power == 0){ $this->SetValue("Zustand_WP", 2); $this->SetValue("CurrentPower", 0); @@ -211,12 +195,6 @@ class WP_Steuerung extends IPSModule { $this->SetValue("Zustand_WP", 1); $this->SetValue("CurrentPower", 0); - if($its_lock_time){ - $this->SetValue("Zustand_WP", 2); - $this->SetValue("CurrentPower", 0); - - } - } } @@ -277,7 +255,9 @@ class WP_Steuerung extends IPSModule { $this->SetValue("PowerSteps", json_encode([$this->GetValue("CurrentPower")])); - }else{ + } + + else{ $this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("WP_Leistung")])); diff --git a/library.json b/library.json index 682742d..dfa774f 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.127", + "version": "0.128", "build": 0, "date": 0 } \ No newline at end of file