From 3a49d32854f59a5b69e9fca5f06f9cdcf16df1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fliger?= Date: Thu, 3 Jul 2025 16:28:05 +0200 Subject: [PATCH] no message --- PV_Visu/module.php | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/PV_Visu/module.php b/PV_Visu/module.php index 920cf11..6bfebc3 100644 --- a/PV_Visu/module.php +++ b/PV_Visu/module.php @@ -37,7 +37,7 @@ class PV_Visu extends IPSModule $data = $this->UpdateData(); return $data; // ← sendet Daten direkt an die Visualisierung } - throw new \Exception("Unknown Ident: $Ident"); + throw new Exception("Unknown Ident: $Ident"); } public function UpdateData() @@ -91,50 +91,7 @@ class PV_Visu extends IPSModule return $html . $initialData; } - public function RequestAction($Ident, $Value) - { - if ($Ident === 'update') { - return $this->UpdateData(); - } - throw new \Exception("Unknown Ident: $Ident"); - } - public function UpdateData() - { - $start = strtotime('today 00:00'); - $end = time(); - - $prod = $this->GetDailyTotal($this->ReadPropertyInteger('VarProduction'), $start, $end); - $cons = $this->GetDailyTotal($this->ReadPropertyInteger('VarConsumption'), $start, $end); - $feed = $this->GetDailyTotal($this->ReadPropertyInteger('VarFeedIn'), $start, $end); - $grid = $this->GetDailyTotal($this->ReadPropertyInteger('VarGrid'), $start, $end); - - $prodCons = $prod > 0 ? (($cons - $grid) / $prod) * 100 : 0; - $prodFeed = $prod > 0 ? 100 - $prodCons : 0; - $consPV = $cons > 0 ? min($prod, ($cons - $grid)) / $cons * 100 : 0; - $consGrid = $cons > 0 ? 100 - $consPV : 0; - - $data = [ - 'prodCons' => round($prodCons, 1), - 'prodFeed' => round($prodFeed, 1), - 'consPV' => round($consPV, 1), - 'consGrid' => round($consGrid, 1), - 'value' => [ - 'prod' => round($prod, 2), - 'cons' => round($cons, 2), - 'feed' => round($feed, 2), - 'grid' => round($grid, 2), - ], - ]; - - $json = json_encode($data); - IPS_LogMessage("PV_Visu", "UpdateData: $json"); - - SetValueString($this->GetIDForIdent('JSONData'), $json); - $this->UpdateVisualizationValue($json); - - return $data; - } private function GetDailyTotal(int $varID, int $start, int $end) {