no message

This commit is contained in:
2025-12-11 14:07:26 +01:00
parent 7daa8b7671
commit f3e7d81fb5

View File

@@ -306,30 +306,43 @@ class Abrechnung extends IPSModule
}
}
// Überspringe Fälle, in denen kein Stromverbrauch und keine Einspeisung vorhanden ist
// Logging der Eingangswerte
IPS_LogMessage("KostenModul", "impTotal: $impTotal | expTotal: $expTotal");
// Fall 1: Weder Import noch Export -> nichts zu berechnen
if ($impTotal == 0.0 && $expTotal == 0.0) {
$ratio = 0.0;
$pvCoversAll = true; // Kein Verbrauch => PV deckt "alles"
} else {
IPS_LogMessage("KostenModul", "Beide Werte sind 0 -> continue()");
continue;
}
// Verhältnis PV / Netz pro User
if ($impTotal == 0.0) {
// Kein Import, nur Export vorhanden
if ($impTotal == 0.0 && $expTotal > 0.0) {
// Kein Import, aber Export → PV deckt alles
$ratio = 0.0;
$pvCoversAll = true; // PV deckt alles
} elseif ($expTotal == 0.0) {
// Kein Export, nur Import vorhanden
$ratio = 0.0;
$pvCoversAll = false; // PV deckt nichts
} elseif ($impTotal <= $expTotal) {
// PV deckt mehr als Import
$ratio = $impTotal / $expTotal;
$pvCoversAll = true;
} else {
// PV deckt weniger als Import
$ratio = $expTotal / $impTotal;
IPS_LogMessage("KostenModul", "Fall: impTotal=0, expTotal>0 -> PV deckt alles");
} elseif ($expTotal == 0.0 && $impTotal > 0.0) {
// Kein Export, aber Import → Netz deckt alles
$ratio = 0.0;
$pvCoversAll = false;
IPS_LogMessage("KostenModul", "Fall: expTotal=0, impTotal>0 -> Netz deckt alles");
} elseif ($impTotal <= $expTotal) {
// PV produziert genug oder mehr
$ratio = $expTotal > 0 ? ($impTotal / $expTotal) : 0.0;
$pvCoversAll = true;
IPS_LogMessage("KostenModul", "Fall: impTotal <= expTotal -> PV deckt genug");
} else {
// Import ist größer als Export → Netz deckt den Rest
$ratio = $impTotal > 0 ? ($expTotal / $impTotal) : 0.0;
$pvCoversAll = false;
IPS_LogMessage("KostenModul", "Fall: impTotal > expTotal -> Netz deckt den Rest");
}
}
IPS_LogMessage("KostenModul", "Ergebnis ratio=$ratio | pvCoversAll=" . ($pvCoversAll ? "true" : "false"));
// Werte pro Zähler verteilen
foreach ($slot as $name => $v) {