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