neuer versuch
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"elements": [
|
||||
{ "type": "SelectVariable", "name": "VarProduction", "caption": "Produktion (kWh)" },
|
||||
{ "type": "SelectVariable", "name": "VarConsumption", "caption": "Verbrauch (kWh)" },
|
||||
{ "type": "SelectVariable", "name": "VarFeedIn", "caption": "Einspeisung (kWh)" },
|
||||
{ "type": "SelectVariable", "name": "VarGrid", "caption": "Bezug Netz (kWh)" }
|
||||
],
|
||||
"actions": []
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
.bar-container { width:100%; background:#eee; border-radius:4px; overflow:hidden; height:18px; margin-bottom:8px; }
|
||||
.bar { height:100%; float:left; }
|
||||
.bar-cons { background:#4CAF50; }
|
||||
.bar-feed { background:#8BC34A; }
|
||||
.bar-pv { background:#FF9800; }
|
||||
.bar-grid { background:#FF5722; }
|
||||
.label { font-size:0.9em; margin:4px 0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="label" id="prodLabel"></div>
|
||||
<div class="bar-container">
|
||||
<div class="bar bar-cons" id="barCons"></div>
|
||||
<div class="bar bar-feed" id="barFeed"></div>
|
||||
</div>
|
||||
<div class="label" id="consLabel"></div>
|
||||
<div class="bar-container">
|
||||
<div class="bar bar-pv" id="barPV"></div>
|
||||
<div class="bar bar-grid" id="barGrid"></div>
|
||||
</div>
|
||||
<script>
|
||||
function Apply(data) {
|
||||
document.getElementById('prodLabel').innerText = "Produktion: " + data.value.prod + " kWh";
|
||||
document.getElementById('barCons').style.width = data.prodCons + "%";
|
||||
document.getElementById('barFeed').style.width = data.prodFeed + "%";
|
||||
document.getElementById('consLabel').innerText = "Verbrauch: " + data.value.cons + " kWh";
|
||||
document.getElementById('barPV').style.width = data.consPV + "%";
|
||||
document.getElementById('barGrid').style.width = data.consGrid + "%";
|
||||
}
|
||||
function handleMessage(msg) { if(msg) Apply(msg); }
|
||||
requestAction('update', true);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{DDE89CBE-4411-5FF4-4931-14204E05CAD0}",
|
||||
"name": "PV_Visu",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "PV",
|
||||
"url": ""
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
class PV_Visu extends IPSModule
|
||||
{
|
||||
public function Create()
|
||||
{
|
||||
parent::Create();
|
||||
$this->RegisterPropertyInteger('VarProduction', 0);
|
||||
$this->RegisterPropertyInteger('VarConsumption', 0);
|
||||
$this->RegisterPropertyInteger('VarFeedIn', 0);
|
||||
$this->RegisterPropertyInteger('VarGrid', 0);
|
||||
$this->SetVisualizationType(3);
|
||||
}
|
||||
|
||||
public function GetVisualizationTile(int $InstanceID): string
|
||||
{
|
||||
$file = __DIR__ . '/module.html';
|
||||
if (!file_exists($file)) {
|
||||
$this->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'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
# PV_Visu
|
||||
|
||||
Visualisierung des Eigenverbrauchs: Tages-Quoten für PV-Produktion vs. Einspeisung und Verbrauch vs. Netz-Bezug.
|
||||
|
||||
## Inhaltsverzeichnis
|
||||
|
||||
1. [Funktionsumfang](#funktionsumfang)
|
||||
2. [Voraussetzungen](#voraussetzungen)
|
||||
3. [Installation](#installation)
|
||||
4. [Instanz einrichten](#instanz-einrichten)
|
||||
5. [WebFront](#webfront)
|
||||
6. [PHP-Befehlsreferenz](#php-befehlsreferenz)
|
||||
|
||||
## Funktionsumfang
|
||||
|
||||
- Anzeige von Tages-Quoten (%)
|
||||
- Produktion: Eigenverbrauch vs. Einspeisung
|
||||
- Verbrauch: PV-Anteil vs. Netz-Anteil
|
||||
- Zwei Balkendiagramme
|
||||
- Absolute Tages-Summen (kWh)
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
- IP-Symcon ≥ 7.1
|
||||
- Archiv-Modul aktiviert
|
||||
- Vier kWh-Zähler-Variablen
|
||||
|
||||
## Installation
|
||||
|
||||
1. **Module Store** → Suche nach „PV_Visu“ und installieren
|
||||
2. **Alternativ**: Unter Module → Repositories folgende URL hinzufügen:
|
||||
```
|
||||
https://github.com/DeinRepo/PV_Visu.git
|
||||
```
|
||||
und Modul neu einlesen.
|
||||
|
||||
## Instanz einrichten
|
||||
|
||||
- **Instanz hinzufügen** → Filter: „PV_Visu“
|
||||
- Variablen zuweisen:
|
||||
|
||||
| Property | Beschreibung |
|
||||
| -------------- | -------------------------- |
|
||||
| VarProduction | PV-Produktionszähler (kWh) |
|
||||
| VarConsumption | Gesamtverbrauch (kWh) |
|
||||
| VarFeedIn | Einspeisung (kWh) |
|
||||
| VarGrid | Netz-Bezug (kWh) |
|
||||
|
||||
## WebFront
|
||||
|
||||
- **Tile-Typ:** PV_Visu
|
||||
- Balken 1 (Grün): Produktion
|
||||
- Balken 2 (Orange/Rot): Verbrauch
|
||||
|
||||
## PHP-Befehlsreferenz
|
||||
|
||||
```php
|
||||
IPS_RequestAction($InstanceID, 'update', true);
|
||||
```
|
||||
Reference in New Issue
Block a user