no message

This commit is contained in:
belevo\mh
2025-12-17 07:57:55 +01:00
parent b28d9b94ce
commit 284ed6ff3b

View File

@@ -100,34 +100,59 @@ class Energy_Pie extends IPSModule
/* ===================== CORE LOGIC ======================== */ /* ===================== CORE LOGIC ======================== */
/* ========================================================= */ /* ========================================================= */
private function RecalculateAndPush(): void private function RecalculateAndPush(): void
{ {
$range = $this->ReadAttributeString(self::ATTR_RANGE); $range = $this->ReadAttributeString(self::ATTR_RANGE);
$date = $this->ReadAttributeString(self::ATTR_DATE); $date = $this->ReadAttributeString(self::ATTR_DATE);
[$tStart, $tEnd] = $this->getRange($range, $date); [$tStart, $tEnd] = $this->getRange($range, $date);
$prod = $this->readDelta($this->ReadPropertyInteger('VarProduction'), $tStart, $tEnd); // Deltas aus dem Archiv
$cons = $this->readDelta($this->ReadPropertyInteger('VarConsumption'), $tStart, $tEnd); $prod = $this->readDelta($this->ReadPropertyInteger('VarProduction'), $tStart, $tEnd);
$feed = $this->readDelta($this->ReadPropertyInteger('VarFeedIn'), $tStart, $tEnd); $feed = $this->readDelta($this->ReadPropertyInteger('VarFeedIn'), $tStart, $tEnd);
$grid = $this->readDelta($this->ReadPropertyInteger('VarGrid'), $tStart, $tEnd); $grid = $this->readDelta($this->ReadPropertyInteger('VarGrid'), $tStart, $tEnd);
$payload = [ // Hausverbrauch = Produktion - Einspeisung + Netz
'range' => $range, $house = $prod - $feed + $grid;
'date' => $date,
'tStart' => $tStart,
'tEnd' => $tEnd,
'values' => [
'Produktion' => $prod,
'Verbrauch' => $cons,
'Einspeisung' => $feed,
'Netz' => $grid
]
];
$this->UpdateVisualizationValue(json_encode($payload, JSON_THROW_ON_ERROR)); // optionaler Schutz (z.B. wenn Logs/Resets Mist bauen)
if ($house < 0) {
$house = 0.0;
} }
// Debug ins Log, damit du die Rechnung sofort prüfen kannst
$this->LogMessage(
sprintf(
"EnergyPie | Range=%s Date=%s | %s -> %s | Prod=%.3f Feed=%.3f Grid=%.3f House=%.3f",
$range,
$date,
date('Y-m-d H:i:s', $tStart),
date('Y-m-d H:i:s', $tEnd),
$prod,
$feed,
$grid,
$house
),
KL_NOTIFY
);
$payload = [
'range' => $range,
'date' => $date,
'tStart' => $tStart,
'tEnd' => $tEnd,
'values' => [
'Produktion' => (float)$prod,
'Einspeisung' => (float)$feed,
'Netz' => (float)$grid,
'Hausverbrauch'=> (float)$house
]
];
$this->UpdateVisualizationValue(json_encode($payload, JSON_THROW_ON_ERROR));
}
/* ========================================================= */ /* ========================================================= */
/* ===================== TIME RANGES ======================= */ /* ===================== TIME RANGES ======================= */
/* ========================================================= */ /* ========================================================= */