no message
This commit is contained in:
@@ -107,27 +107,52 @@ class Energy_Pie extends IPSModule
|
||||
|
||||
[$tStart, $tEnd] = $this->getRange($range, $date);
|
||||
|
||||
// Deltas aus dem Archiv
|
||||
$prod = $this->readDelta($this->ReadPropertyInteger('VarProduction'), $tStart, $tEnd);
|
||||
$cons = $this->readDelta($this->ReadPropertyInteger('VarConsumption'), $tStart, $tEnd);
|
||||
$feed = $this->readDelta($this->ReadPropertyInteger('VarFeedIn'), $tStart, $tEnd);
|
||||
$grid = $this->readDelta($this->ReadPropertyInteger('VarGrid'), $tStart, $tEnd);
|
||||
|
||||
// Hausverbrauch = Produktion - Einspeisung + Netz
|
||||
$house = $prod - $feed + $grid;
|
||||
|
||||
// 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' => $prod,
|
||||
'Verbrauch' => $cons,
|
||||
'Einspeisung' => $feed,
|
||||
'Netz' => $grid
|
||||
'Produktion' => (float)$prod,
|
||||
'Einspeisung' => (float)$feed,
|
||||
'Netz' => (float)$grid,
|
||||
'Hausverbrauch'=> (float)$house
|
||||
]
|
||||
];
|
||||
|
||||
$this->UpdateVisualizationValue(json_encode($payload, JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
|
||||
/* ========================================================= */
|
||||
/* ===================== TIME RANGES ======================= */
|
||||
/* ========================================================= */
|
||||
|
||||
Reference in New Issue
Block a user