no message

This commit is contained in:
2025-04-28 09:24:51 +02:00
parent 2784d0ca34
commit 0067a1dce7

View File

@@ -20,7 +20,7 @@ class Verbraucher_Sperrbar extends IPSModule
$this->RegisterVariableInteger("DailyOnTime", "DailyOnTime", "", 0);
$this->RegisterVariableBoolean("IsTimerActive", "IsTimerActive", "", 0);
$this->RegisterVariableBoolean("IstNacht", "IstNacht", "", 0);
$this->RegisterVariableBoolean("Sperrung_Aktiv", "Sperrung_Aktiv", "", false);
$this->RegisterVariableInteger("Letzte_Sperrleistung", "Letzte_Sperrleistung", "", 0);
// Verbraucherspezifischer Timer
@@ -54,7 +54,6 @@ class Verbraucher_Sperrbar extends IPSModule
{
parent::ApplyChanges();
$this->SetTimerInterval("Timer_Do_UserCalc_Verb",$this->ReadPropertyInteger("Interval")*1000);
}
public function RequestAction($Ident, $Value)
@@ -68,10 +67,10 @@ class Verbraucher_Sperrbar extends IPSModule
case "GetCurrentData":
$this->SetValue("Is_Peak_Shaving", (bool)$Value);
break;
case "ResetPowerSteps":
$this->ResetPowerSteps($Value);
break;
case "ResetTimer":
$this->ResetTimer();
break;
case "Do_UserCalc":
$this->SetAktuelle_Leistung($this->GetValue("Power"));
@@ -90,62 +89,50 @@ class Verbraucher_Sperrbar extends IPSModule
public function SetTimerOn()
{
// Timer setzen, der nach "Zeit_Zwischen_Zustandswechseln" abläuft
$zeitZwischenZustandswechseln = $this->ReadPropertyInteger(
"Zeit_Zwischen_Zustandswechseln"
);
$this->SetTimerInterval(
"ZustandswechselTimer",
$zeitZwischenZustandswechseln * 60000
); // Timer in Millisekunden
IPS_LogMessage("Verbraucher", "In Set Methode");
$zeitZwischenZustandswechseln = $this->ReadPropertyInteger("Zeit_Zwischen_Zustandswechseln");
$this->SetTimerInterval("ZustandswechselTimer", $zeitZwischenZustandswechseln * 60000); // Timer in Millisekunden
// Timer-Status auf true setzen
$this->SetValue("IsTimerActive", true);
}
// Methode zum Zurücksetzen von PowerSteps nach Ablauf des Timers
public function ResetPowerSteps()
public function ResetTimer()
{
// PowerSteps wieder auf den ursprünglichen Zustand setzen (wie vorherige Funktionalität)
$this->SetValue(
"PowerSteps",
json_encode([$this->GetValue("Aktuelle_Leistung")])
);
// Timer stoppen
$this->SetTimerInterval("ZustandswechselTimer", 0);
// Timer-Status auf false setzen
$this->SetValue("IsTimerActive", false);
}
// Methode zum Setzen des aktuellen Stromverbrauchs
public function SetAktuelle_Leistung(float $power)
{
// Hier eine Leistungsänderung detektieren für Idle und interne Mindestlaufzeiten
$this->CheckIdle($power);
if ($this->GetValue("Aktuelle_Leistung") != $power) {
$this->SetTimerOn();
}
$this->SetValue("Aktuelle_Leistung", $power);
// Verbrauchte Energie berechnen
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
$Leistung = GetValue($this->ReadPropertyInteger("Leistung"));
$schaltkontaktID = $this->ReadPropertyInteger("Schaltkontakt1");
if ($this->GetValue("Sperrung_Aktiv") && $power == 0) {
if ($this->GetValue("Is_Peak_Shaving") == false) {
$schaltkontaktStatus = false;
} elseif($power==0 && ((GetValue($schaltkontaktID)==true)||($Leistung>=$this->ReadPropertyInteger("Mindestsperrleistung")))){
$schaltkontaktStatus = true;
} else{
}else{
$schaltkontaktStatus = false;
}
$currentStatus = GetValue($this->ReadPropertyInteger("Schaltkontakt1"));
// Schaltkontaktstatus ändern
SetValue(
$this->ReadPropertyInteger("Schaltkontakt1"),
$schaltkontaktStatus
);
SetValue($this->ReadPropertyInteger("Schaltkontakt1"), $schaltkontaktStatus);
if ($schaltkontaktStatus==true) {
$this->SetValue("DailyOnTime", $this->GetValue("DailyOnTime") + 1);
@@ -164,45 +151,35 @@ class Verbraucher_Sperrbar extends IPSModule
$this->SetValue("IstNacht", $NeuesIstNacht);
$istSperre = $this->GetValue("Sperrung_Aktiv");
if(GetValue($this->ReadPropertyInteger("Leistung"))>=$this->ReadPropertyInteger("Mindestsperrleistung")){
$this->SetValue("Letzte_Sperrleistung", GetValue($this->ReadPropertyInteger("Leistung"))) ;
}
if($istSperre ==false && GetValue($this->ReadPropertyInteger("Leistung"))>=$this->ReadPropertyInteger("Mindestsperrleistung")){
$istSperre = true;
$this->SetValue("Sperrung_Aktiv", true);
}elseif($istSperre ==true && GetValue($this->ReadPropertyInteger("Leistung"))<$this->ReadPropertyInteger("Mindestsperrleistung")){
$istSperre = false;
$this->SetValue("Sperrung_Aktiv", false);
// Überprüfen, ob der Timer aktiv ist
if ($this->GetValue("IsTimerActive")) {
// Timer ist aktiv, PowerSteps setzen
$this->SetValue("PowerSteps", json_encode([$this->GetValue("Aktuelle_Leistung")]));
return;
}
$DailyOnTime = $this->GetValue("DailyOnTime");
$maxlaufzeit = $this->ReadPropertyInteger("MaxSperrZeit") * 60 * 60 / $this->ReadPropertyInteger("Interval");
// Überprüfen, ob der Timer aktiv ist
if ($this->GetValue("IsTimerActive")) {
// Timer ist aktiv, PowerSteps setzen
$this->SetValue(
"PowerSteps",
json_encode([$this->GetValue("Aktuelle_Leistung")])
);
}
// Wenn Maxlaufzeit nicht erreicht ist
if($Peak==false){
$this->SetValue("PowerSteps",json_encode([0]));
} // Wenn Maxlaufzeit nicht erreicht ist
elseif ($DailyOnTime < $maxlaufzeit) {
if ($Peak && $istSperre) {
$this->SetValue(
"PowerSteps",
json_encode([
0,
(int)GetValue($this->ReadPropertyInteger("Leistung"))
])
);
if((GetValue($this->ReadPropertyInteger("Leistung"))>=$this->ReadPropertyInteger("Mindestsperrleistung")) || GetValue($this->ReadPropertyInteger("Schaltkontakt1"))==true) {
$this->SetValue("PowerSteps", json_encode([0, (int)$this->GetValue("Letzte_Sperrleistung")]));
} else {
$this->SetValue("PowerSteps",json_encode([(int)GetValue($this->ReadPropertyInteger("Leistung"))]));
$this->SetValue("PowerSteps",json_encode([0]));
}
}
// Andernfalls
else {
$this->SetValue("PowerSteps",json_encode([(int)GetValue($this->ReadPropertyInteger("Leistung"))]));
$this->SetValue("PowerSteps",json_encode([$this->GetValue("Letzte_Sperrleistung")]));
}
}
public function CheckIdle($power)