no message
This commit is contained in:
@@ -192,24 +192,74 @@ private function CalculateAllPowerCosts($powerMeters, $tariffs, $from, $to)
|
||||
$expTotal = 0.0;
|
||||
$slot = [];
|
||||
|
||||
// 2a. Deltas je Zähler des Users
|
||||
foreach ($meters as $name => $mm) {
|
||||
$impDelta = 0.0;
|
||||
$expDelta = 0.0;
|
||||
// 2a. Deltas je Zähler des Users
|
||||
IPS_LogMessage("ABR", "---- DELTA-Berechnung für Intervall " . date("H:i", $ts) . " - " . date("H:i", $slotEnd) . " ----");
|
||||
|
||||
if (!empty($mm['importVar']) && IPS_VariableExists((int)$mm['importVar'])) {
|
||||
$impDelta = $this->getDeltaFromArchive((int)$mm['importVar'], $ts, $slotEnd);
|
||||
}
|
||||
if (!empty($mm['exportVar']) && IPS_VariableExists((int)$mm['exportVar'])) {
|
||||
$expDelta = $this->getDeltaFromArchive((int)$mm['exportVar'], $ts, $slotEnd);
|
||||
}
|
||||
foreach ($meters as $name => $mm) {
|
||||
|
||||
if ($impDelta > 0.0 || $expDelta > 0.0) {
|
||||
$slot[$name] = ['imp' => $impDelta, 'exp' => $expDelta];
|
||||
$impTotal += $impDelta;
|
||||
$expTotal += $expDelta;
|
||||
}
|
||||
IPS_LogMessage("ABR", " Prüfe Zähler: $name");
|
||||
IPS_LogMessage("ABR", " ImportVar=" . ($mm['importVar'] ?? 'NULL'));
|
||||
IPS_LogMessage("ABR", " ExportVar=" . ($mm['exportVar'] ?? 'NULL'));
|
||||
|
||||
$impDelta = 0.0;
|
||||
$expDelta = 0.0;
|
||||
|
||||
// --- IMPORT ---
|
||||
if (!empty($mm['importVar'])) {
|
||||
|
||||
$varId = (int)$mm['importVar'];
|
||||
|
||||
if (!IPS_VariableExists($varId)) {
|
||||
IPS_LogMessage("ABR", " ⚠ ImportVar $varId existiert NICHT!");
|
||||
} else {
|
||||
|
||||
IPS_LogMessage("ABR", " → ImportDelta: getDeltaFromArchive($varId, $ts, $slotEnd)");
|
||||
|
||||
$impDelta = $this->getDeltaFromArchive($varId, $ts, $slotEnd);
|
||||
|
||||
IPS_LogMessage("ABR", " Ergebnis ImportDelta=$impDelta");
|
||||
}
|
||||
}
|
||||
|
||||
// --- EXPORT ---
|
||||
if (!empty($mm['exportVar'])) {
|
||||
|
||||
$varId = (int)$mm['exportVar'];
|
||||
|
||||
if (!IPS_VariableExists($varId)) {
|
||||
IPS_LogMessage("ABR", " ⚠ ExportVar $varId existiert NICHT!");
|
||||
} else {
|
||||
|
||||
IPS_LogMessage("ABR", " → ExportDelta: getDeltaFromArchive($varId, $ts, $slotEnd)");
|
||||
|
||||
$expDelta = $this->getDeltaFromArchive($varId, $ts, $slotEnd);
|
||||
|
||||
IPS_LogMessage("ABR", " Ergebnis ExportDelta=$expDelta");
|
||||
}
|
||||
}
|
||||
|
||||
// --- Ergebnis für diesen Zähler ---
|
||||
IPS_LogMessage("ABR", " → Zähler $name: impDelta=$impDelta | expDelta=$expDelta");
|
||||
|
||||
if ($impDelta > 0.0 || $expDelta > 0.0) {
|
||||
|
||||
IPS_LogMessage("ABR", " ✔ Delta > 0 → wird für Intervall übernommen");
|
||||
|
||||
$slot[$name] = [
|
||||
'imp' => $impDelta,
|
||||
'exp' => $expDelta
|
||||
];
|
||||
|
||||
$impTotal += $impDelta;
|
||||
$expTotal += $expDelta;
|
||||
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ✘ Delta = 0 → wird ignoriert");
|
||||
}
|
||||
}
|
||||
|
||||
IPS_LogMessage("ABR", "---- Ende DELTA-Berechnung: impTotal=$impTotal | expTotal=$expTotal ----");
|
||||
|
||||
|
||||
if ($impTotal == 0.0 && $expTotal == 0.0) {
|
||||
continue; // für diesen User in diesem Intervall nichts passiert
|
||||
@@ -460,6 +510,7 @@ private function GetCalculatedPowerCosts($userId)
|
||||
|
||||
return $closest ?? floatval(GetValue($varId));
|
||||
}
|
||||
|
||||
private function getDeltaFromArchive(int $varId, int $tStart, int $tEnd): float
|
||||
{
|
||||
$startValue = $this->GetValueAt($varId, $tStart, false); // Wert davor/zu Beginn
|
||||
|
||||
Reference in New Issue
Block a user