no message

This commit is contained in:
mh
2026-04-17 11:47:47 +02:00
parent 2178860a51
commit 0fc488974a
+19 -30
View File
@@ -490,8 +490,9 @@ class Bat_EV_SDL_V2 extends IPSModule
private function CalculateBatteryDistribution(float $pEvW, float $pSdlW): array
{
{
$calcJsonId = $this->GetIDForIdent("CalcJSON");
// Fallback, falls Variable leer ist oder nicht existiert
if (!IPS_VariableExists($calcJsonId)) {
@@ -621,65 +622,53 @@ private function CalculateBatteryDistribution(float $pEvW, float $pSdlW): array
];
}
$batteriesRaw = json_decode($this->ReadPropertyString("Batteries"));
$totalPower_ist = 0;
foreach ($batteriesRaw as $bat) {
$totalPower_ist += GetValue($bat->register_bat_power);
}
// ----------------------------
// ALT (nicht mehr gebraucht) -> AUSKOMMENTIERT
// ----------------------------
/*
$sumReq = (abs($pEvW) + abs($pSdlW));
$sumReqRel = ($pEvW + $pSdlW);
$sumReq = (abs($pEvW) + abs($pSdlW));
$sumReqRel = ($pEvW + $pSdlW);
if($sumReq==0){
if($sumReq==0){
$this->SetValue("Aktuelle_Leistung_EV", $totalPower_ist / 2);
$this->SetValue("Aktuelle_Leistung_SDL", $totalPower_ist / 2);
}else{
}else{
if($pEvW>=0){
$this->SetValue("Aktuelle_Leistung_EV",((1+($totalPower_ist-$sumReqRel) / $sumReq)) * $pEvW);
}else{
$this->SetValue("Aktuelle_Leistung_EV",((1-($totalPower_ist-$sumReqRel) / $sumReq)) * $pEvW);
}
if($pSdlW>=0){
$this->SetValue("Aktuelle_Leistung_SDL",((1+($totalPower_ist-$sumReqRel) / $sumReq)) * $pSdlW);
}else{
$this->SetValue("Aktuelle_Leistung_SDL",((1-($totalPower_ist-$sumReqRel) / $sumReq)) * $pSdlW);
}
}
/*
$sumReq = (float)($pEvW + $pSdlW);
if (!is_finite($sumReq) || abs($sumReq) < 0.01) {
$this->SetValue("Aktuelle_Leistung_EV", $totalPower_ist / 2);
$this->SetValue("Aktuelle_Leistung_SDL", $totalPower_ist / 2);
} else {
$this->SetValue("Aktuelle_Leistung_EV",($totalPower_ist / $sumReq) * $pEvW);
$this->SetValue("Aktuelle_Leistung_SDL",($totalPower_ist / $sumReq) * $pSdlW);
}
*/
// ----------------------------
// NEU (genau deine gewünschte Logik)
// aktuelle - EV_SOLL = aktuelle SDL
// aktuelle - SDL_SOLL = aktuelle EV
// ----------------------------
$this->SetValue("Aktuelle_Leistung_SDL", $totalPower_ist - $pEvW);
$this->SetValue("Aktuelle_Leistung_EV", $totalPower_ist - $pSdlW);
return $finalOutput;
}
}
private function WriteBatteryPowerSetpoints(array $distribution): void
{