no message

This commit is contained in:
dh
2025-04-14 10:32:03 +02:00
parent 1cff1eeb8e
commit fb671a9f5b
+19 -25
View File
@@ -67,33 +67,25 @@ class Verbraucher_extern extends IPSModule
} }
private function berechneKombinationen(array $verbraucherListe, float $power = null) private function berechneKombinationen(array $verbraucherListe)
{ {
$kombinationen = [];
$this->kombinationenRekursiv($verbraucherListe, [], $kombinationen, $power); $kombinationen = [0];
return $kombinationen;
} foreach ($verbraucherListe as $verbraucher) {
private function kombinationenRekursiv(array $verbraucherListe, array $aktuelleKombi, array &$kombinationen, float $power = null) if ($verbraucher['Read_Var'] == 1) {
{ $tempListe = $kombinationen;
if (empty($verbraucherListe)) { foreach ($tempListe as &$wert) {
$summe = array_sum($aktuelleKombi); $wert += $verbraucher['P_Nenn'];
if ($power === null || $summe <= $power) { }
$kombinationen[] = $summe; unset($wert);
$kombinationen = array_merge($kombinationen, $tempListe);
}
} }
return; $kombinationen = array_unique(sort($kombinationen));
}
$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);
} }
// Methode zum Setzen des aktuellen Stromverbrauchs
public function SetAktuelle_Leistung(float $power) { public function SetAktuelle_Leistung(float $power) {
$this->CheckIdle($power); $this->CheckIdle($power);
@@ -106,15 +98,17 @@ class Verbraucher_extern extends IPSModule
$pNenn = $verbraucher['P_Nenn']; $pNenn = $verbraucher['P_Nenn'];
$this->SetValue($writeVarID, in_array($pNenn, $kombinationen) ? 1 : 0); $this->SetValue($writeVarID, in_array($pNenn, $kombinationen) ? 1 : 0);
} }
$this->SetValue("Leistung_Delta", $power - array_sum($kombinationen)); $this->SetValue("Leistung_Delta", GetValue($this->ReadPropertyInteger("delta_power")));
} }
public function GetCurrentData(bool $Peak) public function GetCurrentData(bool $Peak)
{ {
$this->SetValue("Is_Peak_Shaving", $Peak); $this->SetValue("Is_Peak_Shaving", $Peak);
SetValue($this->ReadPropertyInteger("Is_Peak"), $Peak);
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true); $verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
$kombinationen = $this->berechneKombinationen($verbraucherListe); $kombinationen = $this->berechneKombinationen($verbraucherListe);
$this->SetValue("PowerSteps", implode(", ", $kombinationen)); $this->SetValue("PowerSteps", json_encode($kombinationen));
} }