no message
This commit is contained in:
@@ -118,10 +118,18 @@ class Ladestation_v2 extends IPSModule
|
||||
}
|
||||
break;
|
||||
|
||||
case "Sperre_Prio":
|
||||
$this->SetValue("Sperre_Prio", (bool)$Value);
|
||||
break;
|
||||
|
||||
case "PV_Prio":
|
||||
$this->SetValue("PV_Prio", (bool)$Value);
|
||||
break;
|
||||
|
||||
case "Solarladen":
|
||||
$this->SetValue("Solarladen", (bool)$Value);
|
||||
break;
|
||||
|
||||
|
||||
case "Ladebereit":
|
||||
$this->SetValue("Ladebereit", (bool)$Value);
|
||||
break;
|
||||
|
||||
@@ -21,7 +21,13 @@
|
||||
"type": "SelectVariable",
|
||||
"name": "Is_Peak",
|
||||
"caption": "Variable zur Signalisierung der Peakleistung",
|
||||
"suffix": "Sekunden"
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "delta_power",
|
||||
"caption": "Variable mit dem Leistungsunterschied",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "List",
|
||||
@@ -51,19 +57,9 @@
|
||||
"filter": "Verbraucher"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption": "Signal verbracuher ein",
|
||||
"name": "Geschaltet_var",
|
||||
"width": "auto",
|
||||
"add": 0,
|
||||
"edit": {
|
||||
"type": "SelectVariable",
|
||||
"filter": "Verbraucher"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Schaltkontakt1",
|
||||
"name": "P_Nenn",
|
||||
"caption": "Nennleistung des Verbrauchers",
|
||||
"test": true
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class Verbraucher_extern extends IPSModule
|
||||
// Verbraucherspezifische Properties
|
||||
$this->RegisterPropertyString("Verbraucher_Liste", "");
|
||||
$this->RegisterPropertyInteger("Is_Peak", 0);
|
||||
$this->RegisterPropertyInteger("delta_power", 0);
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
@@ -55,10 +56,6 @@ class Verbraucher_extern extends IPSModule
|
||||
$this->SetValue("Is_Peak_Shaving", (bool)$Value);
|
||||
break;
|
||||
|
||||
case "ResetPowerSteps":
|
||||
$this->ResetPowerSteps($Value);
|
||||
break;
|
||||
|
||||
case "Do_UserCalc":
|
||||
$this->SetAktuelle_Leistung($this->GetValue("Power"));
|
||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
||||
@@ -72,121 +69,60 @@ class Verbraucher_extern extends IPSModule
|
||||
|
||||
|
||||
|
||||
// Methode zum Setzen der PowerSteps und Timer starten
|
||||
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");
|
||||
|
||||
// Timer-Status auf true setzen
|
||||
$this->SetValue("IsTimerActive", true);
|
||||
}
|
||||
|
||||
// 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("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)
|
||||
{
|
||||
|
||||
public function SetAktuelle_Leistung(float $power) {
|
||||
$this->CheckIdle($power);
|
||||
if ($this->GetValue("Aktuelle_Leistung") != $power) {
|
||||
$this->SetTimerOn();
|
||||
}
|
||||
$this->SetValue("Aktuelle_Leistung", $power);
|
||||
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
|
||||
|
||||
$boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung");
|
||||
$schaltkontaktID = $this->ReadPropertyInteger("Schaltkontakt1");
|
||||
|
||||
if ($power == $boilerLeistung) {
|
||||
$schaltkontaktStatus = true;
|
||||
} elseif ($power == 0) {
|
||||
$schaltkontaktStatus = false;
|
||||
} else {
|
||||
// Keine Änderung, wenn power nicht 0 oder boilerLeistung entspricht
|
||||
return;
|
||||
}
|
||||
|
||||
$currentStatus = GetValue($this->ReadPropertyInteger("Schaltkontakt1"));
|
||||
|
||||
// Schaltkontaktstatus ändern
|
||||
SetValue(
|
||||
$this->ReadPropertyInteger("Schaltkontakt1"),
|
||||
$schaltkontaktStatus
|
||||
);
|
||||
|
||||
if ($schaltkontaktStatus) {
|
||||
$this->SetValue("DailyOnTime", $this->GetValue("DailyOnTime") + 1);
|
||||
|
||||
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||
$kombinationen = $this->kombinationenRekursiv($verbraucherListe, $power);
|
||||
|
||||
// Setze die Werte in Write_Var
|
||||
foreach ($verbraucherListe as $verbraucher) {
|
||||
$writeVarID = $verbraucher['Write_Var'];
|
||||
$pNenn = $verbraucher['P_Nenn'];
|
||||
$this->SetValue($writeVarID, in_array($pNenn, $kombinationen) ? 1 : 0);
|
||||
}
|
||||
$this->SetValue("Leistung_Delta", $power - array_sum($kombinationen));
|
||||
}
|
||||
|
||||
// Methode zum Abrufen der aktuellen Daten
|
||||
|
||||
// Methode zum Abrufen der aktuellen Daten
|
||||
public function GetCurrentData(bool $Peak)
|
||||
{
|
||||
$IstNacht = $this->GetValue("IstNacht");
|
||||
$NeuesIstNacht = $this->ist_nachts();
|
||||
// Setze die Is_Peak_Shaving Variable
|
||||
$this->SetValue("Is_Peak_Shaving", $Peak);
|
||||
|
||||
if ($IstNacht == true && $NeuesIstNacht == false) {
|
||||
$this->SetValue("DailyOnTime", 0);
|
||||
}
|
||||
|
||||
$this->SetValue("IstNacht", $NeuesIstNacht);
|
||||
|
||||
$DailyOnTime = $this->GetValue("DailyOnTime");
|
||||
$Mindestlaufzeit =
|
||||
$this->ReadPropertyInteger("Mindesttlaufzeit") * 60 * 12;
|
||||
|
||||
// Ü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 Nacht und Mindestlaufzeit nicht erreicht ist
|
||||
elseif ($NeuesIstNacht && $DailyOnTime < $Mindestlaufzeit) {
|
||||
if ($Peak) {
|
||||
$this->SetValue(
|
||||
"PowerSteps",
|
||||
json_encode([
|
||||
0,
|
||||
$this->ReadPropertyInteger("BoilerLeistung"),
|
||||
])
|
||||
);
|
||||
} else {
|
||||
$this->SetValue("PowerSteps",json_encode([$this->ReadPropertyInteger("BoilerLeistung")]));
|
||||
}
|
||||
}
|
||||
// Andernfalls
|
||||
else {
|
||||
if ($Peak) {
|
||||
$this->SetValue("PowerSteps", json_encode([0]));
|
||||
} else {
|
||||
$this->SetValue("PowerSteps",json_encode([0,$this->ReadPropertyInteger("BoilerLeistung"),])
|
||||
);
|
||||
}
|
||||
}
|
||||
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||
$kombinationen = $this->berechneKombinationen($verbraucherListe);
|
||||
$this->SetValue("PowerSteps", implode(", ", $kombinationen));
|
||||
}
|
||||
|
||||
private function berechneKombinationen(array $verbraucherListe, float $power = null)
|
||||
{
|
||||
$kombinationen = [];
|
||||
$this->kombinationenRekursiv($verbraucherListe, [], $kombinationen, $power);
|
||||
return $kombinationen;
|
||||
}
|
||||
|
||||
private function kombinationenRekursiv(array $verbraucherListe, array $aktuelleKombi, array &$kombinationen, float $power = null)
|
||||
{
|
||||
if (empty($verbraucherListe)) {
|
||||
$summe = array_sum($aktuelleKombi);
|
||||
if ($power === null || $summe <= $power) {
|
||||
$kombinationen[] = $summe;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$verbraucher = array_shift($verbraucherListe);
|
||||
if ($this->GetValue($verbraucher['Read_Var']) == 1) {
|
||||
$this->kombinationenRekursiv($verbraucherListe, array_merge($aktuelleKombi, [$verbraucher['P_Nenn']]), $kombinationen, $power);
|
||||
}
|
||||
$this->kombinationenRekursiv($verbraucherListe, $aktuelleKombi, $kombinationen, $power);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function CheckIdle($power)
|
||||
{
|
||||
@@ -205,20 +141,7 @@ class Verbraucher_extern extends IPSModule
|
||||
}
|
||||
}
|
||||
|
||||
private function ist_nachts()
|
||||
{
|
||||
date_default_timezone_set("Europe/Berlin"); // Setze hier deine Zeitzone
|
||||
|
||||
$aktuelle_zeit = strtotime(date("H:i")); // Aktuelle Zeit in Stunden und Minuten umwandeln
|
||||
$start_nacht = strtotime("22:00"); // Startzeit der Nacht (22 Uhr)
|
||||
$ende_nacht = strtotime("07:00"); // Endzeit der Nacht (7 Uhr)
|
||||
|
||||
if ($aktuelle_zeit >= $start_nacht || $aktuelle_zeit < $ende_nacht) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user