diff --git a/PV_Visu/module.html b/PV_Visu/module.html deleted file mode 100644 index 5d09ba6..0000000 --- a/PV_Visu/module.html +++ /dev/null @@ -1,39 +0,0 @@ - - -
- - - - - - - - - - - diff --git a/PV_Visu/module.json b/PV_Visu/module.json index bf567f2..dfbdcba 100644 --- a/PV_Visu/module.json +++ b/PV_Visu/module.json @@ -7,6 +7,6 @@ "parentRequirements": [], "childRequirements": [], "implemented": [], - "prefix": "PV", + "prefix": "", "url": "" } diff --git a/PV_Visu/module.php b/PV_Visu/module.php index 38fa4e7..ec41fbf 100644 --- a/PV_Visu/module.php +++ b/PV_Visu/module.php @@ -1,4 +1,4 @@ -LogMessage("module.html not found in $file", KL_ERROR); - return ''; - } - return $this->Translate(file_get_contents($file)); - } - - public function RequestAction(string $Ident, $Value): void - { - if ($Ident === 'update') { - $this->UpdateData(); - } else { - throw new Exception("Unknown Ident"); - } - } - - protected function UpdateData(): void - { - $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 / $prod) * 100 : 0; - $prodFeed = ($prod > 0) ? ($feed / $prod) * 100 : 0; - $consPV = ($cons > 0) ? min($prod, $cons) / $cons * 100 : 0; - $consGrid = ($cons > 0) ? ($grid / $cons) * 100 : 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) - ] - ]; - - $this->UpdateVisualizationValue($data); - } - - private function GetDailyTotal(int $varID, int $start, int $end): float - { - if ($varID <= 0) { - return 0.0; - } - $archives = IPS_GetInstanceListByModuleID('{43192F11-5B02-4B5D-9B53-8B4DBD4769E9}'); - if (empty($archives)) { - return 0.0; - } - $values = AC_GetAggregatedValues($archives[0], $varID, 1, $start, $end, 1); - if (empty($values)) { - return 0.0; - } - return (float)$values[0]['Avg']; - } } +?> \ No newline at end of file