Mindestlaufzeit eingefühgt für einstufige Verbracuher
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Verbraucher_1_Stufig extends IPSModule {
|
class Verbraucher_1_Stufig extends IPSModule {
|
||||||
|
|
||||||
|
private $timerID;
|
||||||
|
|
||||||
public function Create() {
|
public function Create() {
|
||||||
parent::Create();
|
parent::Create();
|
||||||
|
|
||||||
@@ -22,22 +23,23 @@ class Verbraucher_1_Stufig extends IPSModule {
|
|||||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||||
$this->SetValue("IdleCounter", 0);
|
$this->SetValue("IdleCounter", 0);
|
||||||
|
|
||||||
|
|
||||||
$this->RegisterPropertyInteger("BoilerLeistung", 6000); // Standardwert für Volllast
|
$this->RegisterPropertyInteger("BoilerLeistung", 6000); // Standardwert für Volllast
|
||||||
$this->RegisterPropertyInteger("Mindesttlaufzeit", 4); // Standardwert für Volllast
|
$this->RegisterPropertyInteger("Mindesttlaufzeit", 4); // Standardwert für Volllast
|
||||||
|
$this->RegisterPropertyInteger("Zeit_Zwischen_Zustandswechseln", 1);
|
||||||
$this->RegisterPropertyInteger("Schaltkontakt1", 0);
|
$this->RegisterPropertyInteger("Schaltkontakt1", 0);
|
||||||
|
|
||||||
|
// Timer für Zeit_Zwischen_Zustandswechseln
|
||||||
|
$this->RegisterTimer("ZustandswechselTimer", 0, 'Verbraucher_1_Stufig_ResetPowerSteps($_IPS[\'TARGET\']);');
|
||||||
|
|
||||||
//Initialisieren
|
//Initialisieren
|
||||||
$this->SetValue("Idle", true);
|
$this->SetValue("Idle", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function ApplyChanges() {
|
public function ApplyChanges() {
|
||||||
parent::ApplyChanges();
|
parent::ApplyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aktionen verarbeiten
|
// Aktionen verarbeiten
|
||||||
public function RequestAction($Ident, $Value) {
|
public function RequestAction($Ident, $Value) {
|
||||||
switch ($Ident) {
|
switch ($Ident) {
|
||||||
case "SetCurrentPower":
|
case "SetCurrentPower":
|
||||||
@@ -52,7 +54,6 @@ class Verbraucher_1_Stufig extends IPSModule {
|
|||||||
|
|
||||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||||
public function SetCurrentPower(float $power) {
|
public function SetCurrentPower(float $power) {
|
||||||
|
|
||||||
$this->CheckIdle($power);
|
$this->CheckIdle($power);
|
||||||
$this->SetValue("CurrentPower", $power);
|
$this->SetValue("CurrentPower", $power);
|
||||||
$boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung");
|
$boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung");
|
||||||
@@ -73,62 +74,59 @@ class Verbraucher_1_Stufig extends IPSModule {
|
|||||||
SetValue($this->ReadPropertyInteger("Schaltkontakt1"), $schaltkontaktStatus);
|
SetValue($this->ReadPropertyInteger("Schaltkontakt1"), $schaltkontaktStatus);
|
||||||
|
|
||||||
if($schaltkontaktStatus){
|
if($schaltkontaktStatus){
|
||||||
$this->SetValue("DailyOnTime", $this->GetValue("DailyOnTime")+1);
|
$this->SetValue("DailyOnTime", $this->GetValue("DailyOnTime") + 1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methode zum Setzen der PowerSteps und Timer starten
|
||||||
|
public function SetPowerSteps($powerSteps) {
|
||||||
|
$this->SetValue("PowerSteps", $powerSteps);
|
||||||
|
|
||||||
|
// Timer setzen, der nach "Zeit_Zwischen_Zustandswechseln" abläuft
|
||||||
|
$zeitZwischenZustandswechseln = $this->ReadPropertyInteger("Zeit_Zwischen_Zustandswechseln");
|
||||||
|
$this->SetTimerInterval("ZustandswechselTimer", $zeitZwischenZustandswechseln * 1000); // Timer in Millisekunden
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methode zum Zurücksetzen von PowerSteps nach Ablauf des Timers
|
||||||
|
public function ResetPowerSteps() {
|
||||||
|
// PowerSteps wieder auf den ursprünglichen Zustand setzen (wie vorherige Funktionalität)
|
||||||
|
$this->SetValue("PowerSteps", json_encode([$this->GetValue("CurrentPower")]));
|
||||||
|
|
||||||
|
// Timer stoppen
|
||||||
|
$this->SetTimerInterval("ZustandswechselTimer", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methode zum Abrufen der aktuellen Daten
|
// Methode zum Abrufen der aktuellen Daten
|
||||||
public function GetCurrentData(bool $Peak) {
|
public function GetCurrentData(bool $Peak) {
|
||||||
|
|
||||||
$IstNacht = $this->GetValue("IstNacht");
|
$IstNacht = $this->GetValue("IstNacht");
|
||||||
$NeuesIstNacht = $this->ist_nachts();
|
$NeuesIstNacht = $this->ist_nachts();
|
||||||
|
|
||||||
if($IstNacht==true && $NeuesIstNacht==false){
|
if($IstNacht==true && $NeuesIstNacht==false){
|
||||||
|
|
||||||
$this->SetValue("DailyOnTime", 0);
|
$this->SetValue("DailyOnTime", 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->SetValue("IstNacht", $NeuesIstNacht);
|
$this->SetValue("IstNacht", $NeuesIstNacht);
|
||||||
|
|
||||||
$DailyOnTime = $this->GetValue("DailyOnTime");
|
$DailyOnTime = $this->GetValue("DailyOnTime");
|
||||||
$Mindestlaufzeit = $this->ReadPropertyInteger("Mindesttlaufzeit")*60*12;
|
$Mindestlaufzeit = $this->ReadPropertyInteger("Mindesttlaufzeit") * 60 * 12;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($NeuesIstNacht && ($DailyOnTime<$Mindestlaufzeit)){
|
|
||||||
|
|
||||||
|
if($NeuesIstNacht && ($DailyOnTime < $Mindestlaufzeit)){
|
||||||
if($Peak){
|
if($Peak){
|
||||||
|
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung")]));
|
||||||
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung")]));
|
}else{
|
||||||
|
$this->SetValue("PowerSteps", json_encode([$this->ReadPropertyInteger("BoilerLeistung")]));
|
||||||
}else{
|
}
|
||||||
|
|
||||||
$this->SetValue("PowerSteps", json_encode([$this->ReadPropertyInteger("BoilerLeistung")]));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if($Peak){
|
if($Peak){
|
||||||
|
$this->SetValue("PowerSteps", json_encode([0]));
|
||||||
$this->SetValue("PowerSteps", json_encode([0]));
|
}else{
|
||||||
|
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung")]));
|
||||||
}else{
|
}
|
||||||
|
}
|
||||||
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung")]));
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CheckIdle($power){
|
public function CheckIdle($power){
|
||||||
|
|
||||||
$lastpower = GetValue($this->GetIDForIdent("CurrentPower"));
|
$lastpower = GetValue($this->GetIDForIdent("CurrentPower"));
|
||||||
if($lastpower != $power){
|
if($lastpower != $power){
|
||||||
$this->SetValue("Idle", false);
|
$this->SetValue("Idle", false);
|
||||||
@@ -159,4 +157,4 @@ class Verbraucher_1_Stufig extends IPSModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "0.9",
|
"version": "0.10",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user