no message
This commit is contained in:
@@ -37,7 +37,7 @@ class PV_Visu extends IPSModule
|
|||||||
$data = $this->UpdateData();
|
$data = $this->UpdateData();
|
||||||
return $data; // ← sendet Daten direkt an die Visualisierung
|
return $data; // ← sendet Daten direkt an die Visualisierung
|
||||||
}
|
}
|
||||||
throw new \Exception("Unknown Ident: $Ident");
|
throw new Exception("Unknown Ident: $Ident");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UpdateData()
|
public function UpdateData()
|
||||||
@@ -91,50 +91,7 @@ class PV_Visu extends IPSModule
|
|||||||
return $html . $initialData;
|
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)
|
private function GetDailyTotal(int $varID, int $start, int $end)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user