no message
This commit is contained in:
@@ -1,67 +0,0 @@
|
|||||||
# Manager_1
|
|
||||||
Beschreibung des Moduls.
|
|
||||||
|
|
||||||
### Inhaltsverzeichnis
|
|
||||||
|
|
||||||
1. [Funktionsumfang](#1-funktionsumfang)
|
|
||||||
2. [Voraussetzungen](#2-voraussetzungen)
|
|
||||||
3. [Software-Installation](#3-software-installation)
|
|
||||||
4. [Einrichten der Instanzen in IP-Symcon](#4-einrichten-der-instanzen-in-ip-symcon)
|
|
||||||
5. [Statusvariablen und Profile](#5-statusvariablen-und-profile)
|
|
||||||
6. [WebFront](#6-webfront)
|
|
||||||
7. [PHP-Befehlsreferenz](#7-php-befehlsreferenz)
|
|
||||||
|
|
||||||
### 1. Funktionsumfang
|
|
||||||
|
|
||||||
*
|
|
||||||
|
|
||||||
### 2. Voraussetzungen
|
|
||||||
|
|
||||||
- IP-Symcon ab Version 7.1
|
|
||||||
|
|
||||||
### 3. Software-Installation
|
|
||||||
|
|
||||||
* Über den Module Store das 'Manager_1'-Modul installieren.
|
|
||||||
* Alternativ über das Module Control folgende URL hinzufügen
|
|
||||||
|
|
||||||
### 4. Einrichten der Instanzen in IP-Symcon
|
|
||||||
|
|
||||||
Unter 'Instanz hinzufügen' kann das 'Manager_1'-Modul mithilfe des Schnellfilters gefunden werden.
|
|
||||||
- Weitere Informationen zum Hinzufügen von Instanzen in der [Dokumentation der Instanzen](https://www.symcon.de/service/dokumentation/konzepte/instanzen/#Instanz_hinzufügen)
|
|
||||||
|
|
||||||
__Konfigurationsseite__:
|
|
||||||
|
|
||||||
Name | Beschreibung
|
|
||||||
-------- | ------------------
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
||||||
### 5. Statusvariablen und Profile
|
|
||||||
|
|
||||||
Die Statusvariablen/Kategorien werden automatisch angelegt. Das Löschen einzelner kann zu Fehlfunktionen führen.
|
|
||||||
|
|
||||||
#### Statusvariablen
|
|
||||||
|
|
||||||
Name | Typ | Beschreibung
|
|
||||||
------ | ------- | ------------
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
|
|
||||||
#### Profile
|
|
||||||
|
|
||||||
Name | Typ
|
|
||||||
------ | -------
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
||||||
### 6. WebFront
|
|
||||||
|
|
||||||
Die Funktionalität, die das Modul im WebFront bietet.
|
|
||||||
|
|
||||||
### 7. PHP-Befehlsreferenz
|
|
||||||
|
|
||||||
`boolean GEF_BeispielFunktion(integer $InstanzID);`
|
|
||||||
Erklärung der Funktion.
|
|
||||||
|
|
||||||
Beispiel:
|
|
||||||
`GEF_BeispielFunktion(12345);`
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
{
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type":"List",
|
|
||||||
"name":"Batteries",
|
|
||||||
"caption":"Batterien mit Typ, Leistung und kapazität",
|
|
||||||
"add":true,
|
|
||||||
"delete":true,
|
|
||||||
"columns":[
|
|
||||||
{
|
|
||||||
"caption":"Typ",
|
|
||||||
"name":"typ",
|
|
||||||
"width":"100px",
|
|
||||||
"add":"Stufe",
|
|
||||||
"edit":{
|
|
||||||
"type":"ValidationTextBox"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Leistung in W",
|
|
||||||
"name":"powerbat",
|
|
||||||
"width":"200px",
|
|
||||||
"add":5000,
|
|
||||||
"edit":{
|
|
||||||
"type":"NumberSpinner"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Kapazität in kWh",
|
|
||||||
"name":"capazity",
|
|
||||||
"width":"100px",
|
|
||||||
"add":60,
|
|
||||||
"edit":{
|
|
||||||
"type":"NumberSpinner"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"SoC",
|
|
||||||
"name":"soc",
|
|
||||||
"width":"200px",
|
|
||||||
"add":0,
|
|
||||||
"edit":{
|
|
||||||
"type":"SelectVariable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Batterie SOC-SDL",
|
|
||||||
"name":"sdl_soc",
|
|
||||||
"width":"200px",
|
|
||||||
"add":0,
|
|
||||||
"edit":{
|
|
||||||
"type":"SelectVariable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Batterieleistung Laden SDL",
|
|
||||||
"name":"powerbat_laden_sdl",
|
|
||||||
"width":"200px",
|
|
||||||
"add":0,
|
|
||||||
"edit":{
|
|
||||||
"type":"SelectVariable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Batterieleistung Entladen SDL",
|
|
||||||
"name":"powerbat_entladen_sdl",
|
|
||||||
"width":"200px",
|
|
||||||
"add":0,
|
|
||||||
"edit":{
|
|
||||||
"type":"SelectVariable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Batterie SOC-EV",
|
|
||||||
"name":"ev_soc",
|
|
||||||
"width":"200px",
|
|
||||||
"add":0,
|
|
||||||
"edit":{
|
|
||||||
"type":"SelectVariable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Batterieleistung Laden EV",
|
|
||||||
"name":"powerbat_laden_EV",
|
|
||||||
"width":"200px",
|
|
||||||
"add":0,
|
|
||||||
"edit":{
|
|
||||||
"type":"SelectVariable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Batterieleistung Entladen EV",
|
|
||||||
"name":"powerbat_entladen_ev",
|
|
||||||
"width":"200px",
|
|
||||||
"add":0,
|
|
||||||
"edit":{
|
|
||||||
"type":"SelectVariable"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "SDL_Leistung",
|
|
||||||
"caption": "SDL_Leistung",
|
|
||||||
"suffix": "W"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "UpdateInterval",
|
|
||||||
"caption": "Neuberechnung alle",
|
|
||||||
"suffix": "Minuten",
|
|
||||||
"minimum": 0,
|
|
||||||
"maximum": 1440
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "{5C7A4F8D-B141-1E3A-0D7B-BB187550B220}",
|
|
||||||
"name": "Bat_EV_SDL",
|
|
||||||
"type": 3,
|
|
||||||
"vendor": "Belevo AG",
|
|
||||||
"aliases": [],
|
|
||||||
"parentRequirements": [],
|
|
||||||
"childRequirements": [],
|
|
||||||
"implemented": [],
|
|
||||||
"prefix": "GEF",
|
|
||||||
"url": ""
|
|
||||||
}
|
|
||||||
@@ -1,372 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class Bat_EV_SDL extends IPSModule
|
|
||||||
{
|
|
||||||
public function Create()
|
|
||||||
{
|
|
||||||
parent::Create();
|
|
||||||
|
|
||||||
// Properties
|
|
||||||
$this->RegisterPropertyString("Batteries", "[]");
|
|
||||||
$this->RegisterPropertyInteger("SDL_Leistung", 0); // W
|
|
||||||
$this->RegisterPropertyInteger("UpdateInterval", 5); // Minuten
|
|
||||||
|
|
||||||
// Status
|
|
||||||
$this->RegisterVariableBoolean("State", "Aktiv", "~Switch", 1);
|
|
||||||
$this->EnableAction("State");
|
|
||||||
|
|
||||||
// Prozentwerte
|
|
||||||
$this->RegisterVariableFloat("SDL_Pos", "SDL Energie verfügbar (%)", "", 10);
|
|
||||||
$this->RegisterVariableFloat("SoC_EV", "EV Energie verfügbar (%)", "", 11);
|
|
||||||
|
|
||||||
// Leistungsgrenzen
|
|
||||||
$this->RegisterVariableFloat("Nennleistung_Soll_EV", "Nennleistung Soll EV", "", 2);
|
|
||||||
$this->RegisterVariableFloat("Nennleistung_Soll_SDL", "Nennleistung Soll EV", "", 3);
|
|
||||||
$this->RegisterVariableFloat("P_SDL_laden", "P SDL laden max (W)", "", 21);
|
|
||||||
$this->RegisterVariableFloat("P_SDL_entladen", "P SDL entladen max (W)", "", 22);
|
|
||||||
$this->RegisterVariableFloat("P_EV_laden", "P EV laden max (W)", "", 31);
|
|
||||||
$this->RegisterVariableFloat("P_EV_entladen", "P EV entladen max (W)", "", 32);
|
|
||||||
|
|
||||||
// Debug
|
|
||||||
$this->RegisterVariableString("CalcJSON", "Berechnung (JSON)", "", 99);
|
|
||||||
|
|
||||||
// Timer (korrekt: Klassenname_Update)
|
|
||||||
$this->RegisterTimer("UpdateTimer", 0, 'GEF_Update($_IPS["TARGET"]);');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function ApplyChanges()
|
|
||||||
{
|
|
||||||
parent::ApplyChanges();
|
|
||||||
|
|
||||||
$intervalMin = (int)$this->ReadPropertyInteger("UpdateInterval");
|
|
||||||
$this->SetTimerInterval("UpdateTimer", ($intervalMin > 0) ? $intervalMin * 60 * 1000 : 0);
|
|
||||||
|
|
||||||
$this->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function RequestAction($Ident, $Value)
|
|
||||||
{
|
|
||||||
if ($Ident === "State") {
|
|
||||||
SetValue($this->GetIDForIdent("State"), (bool)$Value);
|
|
||||||
if ((bool)$Value) {
|
|
||||||
$this->Update();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception("Invalid Ident: " . $Ident);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (!GetValue($this->GetIDForIdent("State"))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$batteries = json_decode($this->ReadPropertyString("Batteries"), true);
|
|
||||||
if (!is_array($batteries)) {
|
|
||||||
$batteries = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$sdlTotalW = (float)$this->ReadPropertyInteger("SDL_Leistung"); // W
|
|
||||||
if ($sdlTotalW < 0) $sdlTotalW = 0;
|
|
||||||
|
|
||||||
$sdlTotalkW = $sdlTotalW / 1000.0;
|
|
||||||
|
|
||||||
|
|
||||||
// 30 Minuten Fenster
|
|
||||||
$hours = 0.5;
|
|
||||||
|
|
||||||
// Summe Batterie-Maxleistungen
|
|
||||||
$sumBatPowerW = 0.0;
|
|
||||||
foreach ($batteries as $b) {
|
|
||||||
$p = (float)($b["powerbat"] ?? 0);
|
|
||||||
if ($p > 0) $sumBatPowerW += $p;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($sumBatPowerW <= 0.0) {
|
|
||||||
$this->WriteAllZero("sumBatPowerW=0");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sumBatPowerkW = $sumBatPowerW / 1000.0;
|
|
||||||
|
|
||||||
$calc = [
|
|
||||||
"inputs" => [
|
|
||||||
"SDL_Leistung_W" => round($sdlTotalW, 0),
|
|
||||||
"SumBatPower_W" => round($sumBatPowerW, 0),
|
|
||||||
"hours" => $hours
|
|
||||||
],
|
|
||||||
"batteries" => [],
|
|
||||||
"total" => []
|
|
||||||
];
|
|
||||||
|
|
||||||
// Summen
|
|
||||||
$sdlDisKW_ges = 0.0;
|
|
||||||
$evDisKW_ges = 0.0;
|
|
||||||
$sdlChKW_ges = 0.0;
|
|
||||||
$evChKW_ges = 0.0;
|
|
||||||
|
|
||||||
$real_kWh_ev_ges = 0.0;
|
|
||||||
$real_kWh_sdl_ges = 0.0;
|
|
||||||
|
|
||||||
$SDL_kWh_ges = 0.0;
|
|
||||||
$EV_kWh_ges = 0.0;
|
|
||||||
$totalCapKWh = 0.0;
|
|
||||||
|
|
||||||
foreach ($batteries as $idx => $b) {
|
|
||||||
|
|
||||||
$pBatW = max(0.0, (float)($b["powerbat"] ?? 0));
|
|
||||||
$pBatkW = $pBatW / 1000.0;
|
|
||||||
|
|
||||||
$capKWh = max(0.0, (float)($b["capazity"] ?? 0));
|
|
||||||
|
|
||||||
// soc ist SelectVariable -> Variable-ID
|
|
||||||
$socVarId = (int)($b["soc"] ?? 0);
|
|
||||||
$socPct = $this->ReadSocPercent($socVarId);
|
|
||||||
|
|
||||||
// Defaults pro Batterie (wichtig, damit nix "hängenbleibt")
|
|
||||||
$EV_SOC = 0.0;
|
|
||||||
$SDL_SOC = 0.0;
|
|
||||||
|
|
||||||
$sdlDisKW = 0.0;
|
|
||||||
$evDisKW = 0.0;
|
|
||||||
$sdlChKW = 0.0;
|
|
||||||
$evChKW = 0.0;
|
|
||||||
|
|
||||||
$real_kWh_ev = 0.0;
|
|
||||||
$real_kWh_sdl = 0.0;
|
|
||||||
|
|
||||||
// Wenn Kapazität 0 ist: Batterie überspringen (sonst Divisionen/Unsinn)
|
|
||||||
if ($capKWh <= 0.0) {
|
|
||||||
$calc["batteries"][] = [
|
|
||||||
"idx" => $idx,
|
|
||||||
"typ" => (string)($b["typ"] ?? ("Bat " . ($idx + 1))),
|
|
||||||
"P_bat_W" => round($pBatW, 0),
|
|
||||||
"Cap_kWh" => round($capKWh, 3),
|
|
||||||
"SoC_varId" => $socVarId,
|
|
||||||
"SoC_pct" => round($socPct, 3),
|
|
||||||
"error" => "capazity=0"
|
|
||||||
];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deine Logik: SDL/EV Aufteilung über Leistungsanteil
|
|
||||||
$sdlShareKW = ($sumBatPowerkW > 0.0) ? ($sdlTotalkW / $sumBatPowerkW * $pBatkW) : 0.0;
|
|
||||||
$evShareKW = $pBatkW - $sdlShareKW;
|
|
||||||
|
|
||||||
// untere Grenze für SDL (wichtig: zuerst setzen, dann clamp)
|
|
||||||
$underKWh = $sdlShareKW * $hours;
|
|
||||||
$underKWh = max(0.0, min($underKWh, $capKWh / 2.0));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$upKWh = $capKWh - $underKWh;
|
|
||||||
$SDL_kWh = 2.0 * $underKWh;
|
|
||||||
$EV_kWH = max(0.0, $capKWh - $SDL_kWh);
|
|
||||||
|
|
||||||
|
|
||||||
$real_kWh = $capKWh / 100.0 * $socPct;
|
|
||||||
|
|
||||||
// --- Deine 3 Fälle (minimal abgesichert, keine Änderung der Grundfunktion) ---
|
|
||||||
if ($underKWh <= $real_kWh && $upKWh >= $real_kWh) {
|
|
||||||
|
|
||||||
$SDL_SOC = 50.0;
|
|
||||||
$EV_SOC = ($capKWh > 0.0) ? (($real_kWh - $underKWh) * 100.0 / $capKWh) : 0.0;
|
|
||||||
|
|
||||||
$sdlDisKW = $sdlShareKW;
|
|
||||||
$evDisKW = $evShareKW;
|
|
||||||
$sdlChKW = $sdlShareKW;
|
|
||||||
$evChKW = $evShareKW;
|
|
||||||
|
|
||||||
$real_kWh_ev = $real_kWh - $underKWh;
|
|
||||||
$real_kWh_sdl = $underKWh;
|
|
||||||
|
|
||||||
} elseif ($upKWh < $real_kWh) {
|
|
||||||
|
|
||||||
$EV_SOC = 100.0;
|
|
||||||
|
|
||||||
// Division absichern
|
|
||||||
$den = ($capKWh - $real_kWh + $underKWh);
|
|
||||||
$SDL_SOC = ($den > 0.0) ? ( $den / (2.0 * $underKWh) * 100.0) : 0.0;
|
|
||||||
|
|
||||||
$sdlDisKW = $sdlShareKW;
|
|
||||||
$evDisKW = $evShareKW;
|
|
||||||
$sdlChKW = $sdlShareKW;
|
|
||||||
$evChKW = 0.0;
|
|
||||||
|
|
||||||
$real_kWh_ev = $capKWh - 2.0 * $underKWh;
|
|
||||||
$real_kWh_sdl = (2.0 * $underKWh) - ($capKWh - $real_kWh);
|
|
||||||
|
|
||||||
} elseif ($underKWh > $real_kWh) {
|
|
||||||
|
|
||||||
$EV_SOC = 0.0;
|
|
||||||
|
|
||||||
$den = 2.0 * $underKWh;
|
|
||||||
$SDL_SOC = ($den > 0.0) ? ($real_kWh * 100.0 / $den) : 0.0;
|
|
||||||
|
|
||||||
$sdlDisKW = $sdlShareKW;
|
|
||||||
$evDisKW = 0.0;
|
|
||||||
$sdlChKW = $sdlShareKW;
|
|
||||||
$evChKW = $evShareKW;
|
|
||||||
|
|
||||||
$real_kWh_ev = 0.0;
|
|
||||||
$real_kWh_sdl = $real_kWh;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Null/Full Abdeckung (dein Verhalten beibehalten, aber clampen)
|
|
||||||
if ($real_kWh <= 0.0) {
|
|
||||||
$sdlDisKW = 0.0;
|
|
||||||
$real_kWh_ev = 0.0;
|
|
||||||
$real_kWh_sdl = 0.0;
|
|
||||||
} elseif ($real_kWh >= $capKWh) {
|
|
||||||
$sdlChKW = 0.0;
|
|
||||||
|
|
||||||
$real_kWh_ev = $capKWh - 2.0 * $underKWh;
|
|
||||||
$real_kWh_sdl = 2.0 * $underKWh;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Negative "real"-kWh verhindern (nur Sicherheit, sonst knallt später %)
|
|
||||||
$real_kWh_ev = max(0.0, $real_kWh_ev);
|
|
||||||
$real_kWh_sdl = max(0.0, $real_kWh_sdl);
|
|
||||||
|
|
||||||
// Summen
|
|
||||||
$totalCapKWh += $capKWh;
|
|
||||||
|
|
||||||
$sdlDisKW_ges += $sdlDisKW;
|
|
||||||
$evDisKW_ges += $evDisKW;
|
|
||||||
$sdlChKW_ges += $sdlChKW;
|
|
||||||
$evChKW_ges += $evChKW;
|
|
||||||
|
|
||||||
$real_kWh_ev_ges += $real_kWh_ev;
|
|
||||||
$real_kWh_sdl_ges += $real_kWh_sdl;
|
|
||||||
|
|
||||||
$SDL_kWh_ges += $SDL_kWh;
|
|
||||||
$EV_kWh_ges += $EV_kWH;
|
|
||||||
|
|
||||||
// Debug pro Batterie
|
|
||||||
$calc["batteries"][] = [
|
|
||||||
"idx" => $idx,
|
|
||||||
"typ" => (string)($b["typ"] ?? ("Bat " . ($idx + 1))),
|
|
||||||
"P_bat_W" => round($pBatW, 0),
|
|
||||||
"Cap_kWh" => round($capKWh, 3),
|
|
||||||
"SoC_varId" => $socVarId,
|
|
||||||
"SoC_pct" => round($socPct, 3),
|
|
||||||
"Effektive kWh" => round($real_kWh, 3),
|
|
||||||
|
|
||||||
"EV_SOC" => round($EV_SOC, 3),
|
|
||||||
"SDL_SOC" => round($SDL_SOC, 3),
|
|
||||||
|
|
||||||
"EV_kWh" => round($real_kWh_ev, 3),
|
|
||||||
"SDL_kWh" => round($real_kWh_sdl, 3),
|
|
||||||
|
|
||||||
"SDL_Power_kW" => round($sdlShareKW, 3),
|
|
||||||
"EV_Power_kW" => round($evShareKW, 3),
|
|
||||||
|
|
||||||
"under_grenze_kWh" => round($underKWh, 3),
|
|
||||||
"up_grenze_kWh" => round($upKWh, 3),
|
|
||||||
|
|
||||||
"SDL_Charge_kW" => round($sdlChKW, 3),
|
|
||||||
"SDL_Discharge_kW" => round($sdlDisKW, 3),
|
|
||||||
"EV_Charge_kW" => round($evChKW, 3),
|
|
||||||
"EV_Discharge_kW" => round($evDisKW, 3),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prozent gesamt (mit Guards)
|
|
||||||
$evPosPct = ($EV_kWh_ges > 0.0) ? ($real_kWh_ev_ges / $EV_kWh_ges * 100.0) : 0.0;
|
|
||||||
$sdlPosPct = ($SDL_kWh_ges > 0.0) ? ($real_kWh_sdl_ges / $SDL_kWh_ges * 100.0) : 0.0;
|
|
||||||
|
|
||||||
// Werte setzen
|
|
||||||
$this->SetIdentValue("SDL_Pos", round($sdlPosPct, 3));
|
|
||||||
$this->SetIdentValue("SoC_EV", round($evPosPct, 3));
|
|
||||||
|
|
||||||
$this->SetIdentValue("P_SDL_laden", round($sdlChKW_ges * 1000.0, 0));
|
|
||||||
$this->SetIdentValue("P_SDL_entladen", round($sdlDisKW_ges * 1000.0, 0));
|
|
||||||
|
|
||||||
$this->SetIdentValue("P_EV_laden", round($evChKW_ges * 1000.0, 0));
|
|
||||||
$this->SetIdentValue("P_EV_entladen", round($evDisKW_ges * 1000.0, 0));
|
|
||||||
|
|
||||||
$calc["total"] = [
|
|
||||||
"SDL_SoC_pct" => round($sdlPosPct, 3),
|
|
||||||
"EV_SoC_pct" => round($evPosPct, 3),
|
|
||||||
"SDL_kWh_pct" => round($SDL_kWh_ges, 3),
|
|
||||||
"EV_kWh_pct" => round($EV_kWh_ges, 3),
|
|
||||||
"SDL_Charge_kW" => round($sdlChKW_ges, 3),
|
|
||||||
"SDL_Discharge_kW" => round($sdlDisKW_ges, 3),
|
|
||||||
"EV_Charge_kW" => round($evChKW_ges, 3),
|
|
||||||
"EV_Discharge_kW" => round($evDisKW_ges, 3),
|
|
||||||
"totalCap_kWh" => round($totalCapKWh, 3)
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->SetIdentValue("CalcJSON", json_encode($calc, JSON_PRETTY_PRINT));
|
|
||||||
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
// Damit du den echten Fehler siehst (statt -32603)
|
|
||||||
$this->SendDebug("Update ERROR", $e->getMessage() . " @ " . $e->getFile() . ":" . $e->getLine(), 0);
|
|
||||||
$this->WriteAllZero("Exception: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------- Helpers ----------------
|
|
||||||
|
|
||||||
private function WriteAllZero(string $reason): void
|
|
||||||
{
|
|
||||||
$this->SetIdentValue("SDL_Pos", 0.0);
|
|
||||||
$this->SetIdentValue("SoC_EV", 0.0);
|
|
||||||
|
|
||||||
$this->SetIdentValue("P_SDL_laden", 0.0);
|
|
||||||
$this->SetIdentValue("P_SDL_entladen", 0.0);
|
|
||||||
$this->SetIdentValue("P_EV_laden", 0.0);
|
|
||||||
$this->SetIdentValue("P_EV_entladen", 0.0);
|
|
||||||
|
|
||||||
$this->SetIdentValue("CalcJSON", json_encode(["error" => $reason], JSON_PRETTY_PRINT));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function SetIdentValue(string $ident, $value): void
|
|
||||||
{
|
|
||||||
$id = @$this->GetIDForIdent($ident);
|
|
||||||
if ($id <= 0) {
|
|
||||||
$this->SendDebug(__FUNCTION__, "Ident nicht gefunden: $ident", 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SetValue($id, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function ReadSocPercent(int $varId): float
|
|
||||||
{
|
|
||||||
// Falls jemand statt Variable direkt 0..100 einträgt
|
|
||||||
if ($varId >= 0 && $varId <= 100 && !IPS_VariableExists($varId)) {
|
|
||||||
return (float)$varId;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($varId <= 0 || !IPS_VariableExists($varId)) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$v = GetValue($varId);
|
|
||||||
if (!is_numeric($v)) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$soc = (float)$v;
|
|
||||||
|
|
||||||
|
|
||||||
if ($soc < 0.0) $soc = 0.0;
|
|
||||||
if ($soc > 100.0) $soc = 100.0;
|
|
||||||
|
|
||||||
return $soc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -36,13 +36,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NumberSpinner",
|
"type": "SelectVariable",
|
||||||
"name": "MaxBatterieleistung",
|
"name": "MaxBatterieleistung",
|
||||||
"caption": "Maximale Batterieleistung",
|
"caption": "Maximale Batterieleistung",
|
||||||
"suffix": ""
|
"suffix": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NumberSpinner",
|
"type": "SelectVariable",
|
||||||
"name": "MaxNachladen",
|
"name": "MaxNachladen",
|
||||||
"caption": "Maximum Nachladen",
|
"caption": "Maximum Nachladen",
|
||||||
"suffix": ""
|
"suffix": ""
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
{
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "Label",
|
|
||||||
"caption": "Konfiguration der Batterie für Peakshaving"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "IdleCounterMax",
|
|
||||||
"caption": "Zyklen zwischen zwei Leistungsänderungen (Multipliziert sich mit Interval)",
|
|
||||||
"suffix": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "Interval",
|
|
||||||
"caption": "Intervall Neuberechnung der Werte",
|
|
||||||
"suffix": "Sekunden"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type":"Select",
|
|
||||||
"name":"Batterietyp",
|
|
||||||
"caption":"Batterietyp",
|
|
||||||
"options":[
|
|
||||||
{
|
|
||||||
"caption":"Goodwe",
|
|
||||||
"value":1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Solaredge",
|
|
||||||
"value":2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Sig Energy",
|
|
||||||
"value":3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "MaxBatterieleistung",
|
|
||||||
"caption": "Maximale Batterieleistung",
|
|
||||||
"suffix": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "MaxNachladen",
|
|
||||||
"caption": "Maximum Nachladen",
|
|
||||||
"suffix": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "AufdasNachladen",
|
|
||||||
"caption": "Auf so viel Prozent nachladen",
|
|
||||||
"suffix": ""
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "MinimumEntladen",
|
|
||||||
"caption": "Minimum des Batterieladezustand",
|
|
||||||
"suffix": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type":"Select",
|
|
||||||
"name":"Batteriemanagement",
|
|
||||||
"caption":"Batteriemanagement",
|
|
||||||
"options":[
|
|
||||||
{
|
|
||||||
"caption":"Durch Wechselrichter",
|
|
||||||
"value":1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"caption":"Durch EMS Symcon",
|
|
||||||
"value":2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SelectVariable",
|
|
||||||
"name": "Batterieladezustand",
|
|
||||||
"caption": "Batterieladezustand",
|
|
||||||
"test": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SelectVariable",
|
|
||||||
"name": "Netzbezug",
|
|
||||||
"caption": "Variable mit dem zu regelnden Netzbezug"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Label",
|
|
||||||
"caption": "Goodwe: Laden=11, Entladen=12,\nSolaredge: Laden=3, Entladen=4,\nSig Energy: Laden=3, Entladen=6, P in kW"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "{A7FEA6E1-EBAA-1567-C14B-9A63B09C9EDC}",
|
|
||||||
"name": "Batterie_test",
|
|
||||||
"type": 3,
|
|
||||||
"vendor": "Belevo AG",
|
|
||||||
"aliases": [],
|
|
||||||
"parentRequirements": [],
|
|
||||||
"childRequirements": [],
|
|
||||||
"implemented": [],
|
|
||||||
"prefix": "GEF",
|
|
||||||
"url": ""
|
|
||||||
}
|
|
||||||
@@ -1,483 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class Batterie_test extends IPSModule
|
|
||||||
{
|
|
||||||
public function Create()
|
|
||||||
{
|
|
||||||
parent::Create();
|
|
||||||
|
|
||||||
// Batterie spezifische Eigenschaften
|
|
||||||
$this->RegisterPropertyInteger("MaxBatterieleistung", 0);
|
|
||||||
$this->RegisterPropertyInteger("Batteriespannung", 50);
|
|
||||||
$this->RegisterPropertyInteger("AufdasNachladen",0);
|
|
||||||
$this->RegisterPropertyInteger("MinimumEntladen",0);
|
|
||||||
$this->RegisterPropertyInteger("Batterieladezustand",0);
|
|
||||||
$this->RegisterPropertyInteger("Batteriemanagement", 1);
|
|
||||||
$this->RegisterPropertyInteger("Batterietyp", 1);
|
|
||||||
$this->RegisterPropertyInteger("MaxNachladen",0);
|
|
||||||
$this->RegisterPropertyInteger("Netzbezug", 0); // Initialisierung mit 0
|
|
||||||
$this->RegisterPropertyInteger("Interval", 2); // Recheninterval
|
|
||||||
|
|
||||||
|
|
||||||
// Variabeln für Kommunkation mit Manager
|
|
||||||
//$this->RegisterVariableFloat("Entladeleistung","Entladeleistung", "",0);
|
|
||||||
$this->RegisterVariableInteger("Batteriemanagement_Variabel","Batteriemanagement_Variabel", "",0);
|
|
||||||
//$this->RegisterVariableInteger("Laden3_Entladen4","Laden3_Entladen4", "",3);
|
|
||||||
$this->RegisterVariableInteger("Laden_Entladen","Laden_Entladen", "",3);
|
|
||||||
//$this->RegisterVariableFloat("Ladeleistung","Ladeleistung", "",0);
|
|
||||||
//$this->RegisterVariableFloat("Goodwe_EntLadeleistung","Goodwe_EntLadeleistung", "",0);
|
|
||||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
|
||||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
|
||||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
|
||||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
|
||||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
|
||||||
$this->RegisterVariableInteger("Power", "Power");
|
|
||||||
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving");
|
|
||||||
$this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 0);
|
|
||||||
|
|
||||||
$this->RegisterVariableBoolean("Hysterese", "Hysterese","",false);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
|
||||||
|
|
||||||
// Hilfsvariabeln für Idle zustand
|
|
||||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
|
||||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
|
||||||
$this->SetValue("IdleCounter", 0);
|
|
||||||
|
|
||||||
// Initialisiere Idle
|
|
||||||
$this->SetValue("Idle", true);
|
|
||||||
|
|
||||||
$this->RegisterTimer("Timer_Do_UserCalc_Battery",$this->ReadPropertyInteger("Interval")*1000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function ApplyChanges()
|
|
||||||
{
|
|
||||||
parent::ApplyChanges();
|
|
||||||
|
|
||||||
$batterieManagement = $this->ReadPropertyInteger("Batteriemanagement");
|
|
||||||
$this->SetValue("Batteriemanagement_Variabel", $batterieManagement);
|
|
||||||
$this->SetTimerInterval("Timer_Do_UserCalc_Battery",$this->ReadPropertyInteger("Interval")*1000);
|
|
||||||
|
|
||||||
$batterietyp = $this->ReadPropertyInteger("Batterietyp");
|
|
||||||
|
|
||||||
switch ($batterietyp) {
|
|
||||||
case 1: // Goodwe
|
|
||||||
$this->MaintainVariable("Goodwe_EntLadeleistung", "Goodwe_EntLadeleistung", VARIABLETYPE_FLOAT, "", 10, true);
|
|
||||||
$this->MaintainVariable("Ladeleistung", "Ladeleistung", VARIABLETYPE_FLOAT, "", 11, false);
|
|
||||||
$this->MaintainVariable("Entladeleistung", "Entladeleistung", VARIABLETYPE_FLOAT, "", 13, false);
|
|
||||||
$this->MaintainVariable("Laden_Entladen", "Laden_Entladen", VARIABLETYPE_INTEGER, "", 12, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // Solaredge
|
|
||||||
$this->MaintainVariable("Goodwe_EntLadeleistung", "Goodwe_EntLadeleistung", VARIABLETYPE_FLOAT, "", 10, false);
|
|
||||||
$this->MaintainVariable("Ladeleistung", "Ladeleistung", VARIABLETYPE_FLOAT, "", 11, true);
|
|
||||||
$this->MaintainVariable("Entladeleistung", "Entladeleistung", VARIABLETYPE_FLOAT, "", 13, true);
|
|
||||||
$this->MaintainVariable("Laden_Entladen", "Laden_Entladen", VARIABLETYPE_INTEGER, "", 12, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: // SiG Energy
|
|
||||||
$this->MaintainVariable("Goodwe_EntLadeleistung", "Goodwe_EntLadeleistung", VARIABLETYPE_FLOAT, "", 10, false);
|
|
||||||
$this->MaintainVariable("Ladeleistung", "Ladeleistung", VARIABLETYPE_FLOAT, "", 11, true);
|
|
||||||
$this->MaintainVariable("Entladeleistung", "Entladeleistung", VARIABLETYPE_FLOAT, "", 13, true);
|
|
||||||
$this->MaintainVariable("Laden_Entladen", "Laden_Entladen", VARIABLETYPE_INTEGER, "", 12, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Sicherheit: alles weg
|
|
||||||
$this->MaintainVariable("Goodwe_EntLadeleistung", "Goodwe_EntLadeleistung", VARIABLETYPE_FLOAT, "", 10, false);
|
|
||||||
$this->MaintainVariable("Ladeleistung", "Ladeleistung", VARIABLETYPE_FLOAT, "", 11, false);
|
|
||||||
$this->MaintainVariable("Laden_Entladen", "Laden_Entladen", VARIABLETYPE_INTEGER, "", 12, false);
|
|
||||||
$this->MaintainVariable("Entladeleistung", "Entladeleistung", VARIABLETYPE_FLOAT, "", 13, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function GeneratePowerSteps($additionalValue)
|
|
||||||
{
|
|
||||||
$maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung");
|
|
||||||
$stepSize = 250; // Schrittgröße
|
|
||||||
$stepSizeSmall = 50; // Kleine Schrittgröße
|
|
||||||
|
|
||||||
// Array direkt als Range erzeugen (schneller als Schleife)
|
|
||||||
$array_powersteps = range(-$maxleistung, $maxleistung, $stepSize);
|
|
||||||
|
|
||||||
// Nächstgelegenen Wert direkt bestimmen (rundet auf den nächsten Step)
|
|
||||||
$closestValue = round($additionalValue / $stepSize) * $stepSize;
|
|
||||||
|
|
||||||
// Falls der Wert nicht im Bereich liegt, abbrechen
|
|
||||||
if (!in_array($closestValue, $array_powersteps)) {
|
|
||||||
return $array_powersteps;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Index des gefundenen Werts suchen
|
|
||||||
$index = array_search($closestValue, $array_powersteps);
|
|
||||||
|
|
||||||
// Zusätzliche Werte berechnen und auf MaxLeistung begrenzen
|
|
||||||
$newValues = array_filter([
|
|
||||||
$closestValue - 4 * $stepSizeSmall,
|
|
||||||
$closestValue - 3 * $stepSizeSmall,
|
|
||||||
$closestValue - 2 * $stepSizeSmall,
|
|
||||||
$closestValue - $stepSizeSmall,
|
|
||||||
$closestValue,
|
|
||||||
$closestValue + $stepSizeSmall,
|
|
||||||
$closestValue + 2 * $stepSizeSmall,
|
|
||||||
$closestValue + 3 * $stepSizeSmall,
|
|
||||||
$closestValue + 4 * $stepSizeSmall,
|
|
||||||
], function ($value) use ($maxleistung) {
|
|
||||||
return $value >= -$maxleistung && $value <= $maxleistung;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Effizienteres Einfügen der Werte (direkt an der Stelle)
|
|
||||||
array_splice($array_powersteps, $index, 1, $newValues);
|
|
||||||
|
|
||||||
return $array_powersteps;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function RequestAction($Ident, $Value)
|
|
||||||
{
|
|
||||||
switch ($Ident) {
|
|
||||||
|
|
||||||
case "SetAktuelle_Leistung":
|
|
||||||
$this->SetValue("Power", (int)$Value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "GetCurrentData":
|
|
||||||
$this->SetValue("Is_Peak_Shaving", (bool)$Value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case "Do_UserCalc":
|
|
||||||
|
|
||||||
$this->SetAktuelle_Leistung($this->GetValue("Power"));
|
|
||||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new Exception("Invalid Ident");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function SetAktuelle_Leistung(int $power)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
$batterietyp = $this->ReadPropertyInteger("Batterietyp");
|
|
||||||
$batterieManagement = $this->ReadPropertyInteger("Batteriemanagement");
|
|
||||||
|
|
||||||
// Goodwe, Solaredge WR Modus
|
|
||||||
if ($batterieManagement == 1 && ($batterietyp == 1 || $batterietyp == 2)) {
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Batteriemanagement_Variabel", 1);
|
|
||||||
return;
|
|
||||||
//Sig Energy WR Modus
|
|
||||||
} elseif ($batterieManagement == 1 && $batterietyp == 3) {
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Batteriemanagement_Variabel", 0);
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Sig Energy Symcon Modus
|
|
||||||
} elseif ($batterieManagement == 2 && $batterietyp == 3) {
|
|
||||||
$this->SetValue("Batteriemanagement_Variabel", 1);
|
|
||||||
|
|
||||||
//Solaredge Symcon Modus
|
|
||||||
}elseif ($batterieManagement == 2 && $batterietyp == 2) {
|
|
||||||
$this->SetValue("Batteriemanagement_Variabel", 4);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if($this->GetValue("Is_Peak_Shaving")==true){
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Ladeleistung", $power);
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Laden3_Entladen4", 3);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Entladeleistung", abs($power));
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Laden3_Entladen4", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Ladeleistung", $power);
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Laden3_Entladen4", 3);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Entladeleistung", abs($power));
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Laden3_Entladen4", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$batterietyp = $this->ReadPropertyInteger("Batterietyp");
|
|
||||||
if ($batterietyp == 1) {//Goodwe
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
//-----------------------Gooodwee-------------------------------------//
|
|
||||||
if($this->GetValue("Is_Peak_Shaving")==true){
|
|
||||||
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Goodwe_EntLadeleistung", abs($power));
|
|
||||||
$this->SetValue("Laden_Entladen", 11);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Goodwe_EntLadeleistung", abs($power));
|
|
||||||
$this->SetValue("Laden_Entladen", 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Goodwe_EntLadeleistung", abs($power));
|
|
||||||
$this->SetValue("Laden_Entladen", 11);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Goodwe_EntLadeleistung", abs($power));
|
|
||||||
$this->SetValue("Laden_Entladen", 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}elseif ($batterietyp == 2) {//Solaredge
|
|
||||||
|
|
||||||
//-----------------------Solaredge-------------------------------------//
|
|
||||||
$this->SetValue("Goodwe_EntLadeleistung",0);
|
|
||||||
if($this->GetValue("Is_Peak_Shaving")==true){
|
|
||||||
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Ladeleistung", $power);
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 3);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Entladeleistung", abs($power));
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Ladeleistung", $power);
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 3);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Entladeleistung", abs($power));
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif ($batterietyp == 3) {//Sig Energy
|
|
||||||
|
|
||||||
//-----------------------Sig Energy-------------------------------------//
|
|
||||||
$this->SetValue("Goodwe_EntLadeleistung",0);
|
|
||||||
if($this->GetValue("Is_Peak_Shaving")==true){
|
|
||||||
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Ladeleistung", $power/1000);
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 3);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Entladeleistung", abs($power)/1000);
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
if ($power >= 0) {
|
|
||||||
$this->SetValue("Ladeleistung", $power/1000);
|
|
||||||
$this->SetValue("Entladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 3);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Entladeleistung", abs($power)/1000);
|
|
||||||
$this->SetValue("Ladeleistung", 0);
|
|
||||||
$this->SetValue("Laden_Entladen", 6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Prüfe auf Änderung der Leistung im Vergleich zur letzten Einstellung
|
|
||||||
$lastPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
|
||||||
if ($power != $lastPower) {
|
|
||||||
$this->SetValue("Idle", false);
|
|
||||||
$this->SetValue(
|
|
||||||
"IdleCounter",
|
|
||||||
$this->ReadPropertyInteger("IdleCounterMax")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setze die neue aktuelle Leistung
|
|
||||||
$this->SetValue("Aktuelle_Leistung", $power);
|
|
||||||
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
|
|
||||||
|
|
||||||
// IdleCounter verarbeiten
|
|
||||||
$this->ProcessIdleCounter();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function GetCurrentData(bool $Peak)
|
|
||||||
{
|
|
||||||
IPS_LogMessage("Batterie", "Currentdata");
|
|
||||||
|
|
||||||
$array_powersteps = $this->GeneratePowerSteps($this->GetValue("Aktuelle_Leistung"));
|
|
||||||
$aufdasnachladen = $this->ReadPropertyInteger("AufdasNachladen");
|
|
||||||
$minimumentladen = $this->ReadPropertyInteger("MinimumEntladen");
|
|
||||||
$maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung");
|
|
||||||
$dummy_array = [];
|
|
||||||
$batterieladezustand = GetValue($this->ReadPropertyInteger("Batterieladezustand"));
|
|
||||||
$filtered_powersteps_entladen = [];
|
|
||||||
if ($this->ReadPropertyInteger("Batteriemanagement") == 1) {
|
|
||||||
$dummy_array[] = 0;
|
|
||||||
return $this->SetValue("PowerSteps", json_encode($dummy_array));
|
|
||||||
}
|
|
||||||
|
|
||||||
$netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug"));
|
|
||||||
if (abs($netzbezug) > $maxleistung) {
|
|
||||||
$netzbezug = $maxleistung * (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($batterieladezustand>(5+$aufdasnachladen)){
|
|
||||||
|
|
||||||
$this->SetValue("Hysterese", false);
|
|
||||||
|
|
||||||
}elseif($batterieladezustand<=$aufdasnachladen){
|
|
||||||
$this->SetValue("Hysterese", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$hyst = $this->GetValue("Hysterese");
|
|
||||||
|
|
||||||
if($Peak){
|
|
||||||
IPS_LogMessage("Batterie", "Im if teil");
|
|
||||||
|
|
||||||
if($batterieladezustand>$aufdasnachladen && $hyst==false){
|
|
||||||
|
|
||||||
$dummy_array[] = $netzbezug;
|
|
||||||
$this->SetValue("PowerSteps", json_encode($dummy_array));
|
|
||||||
|
|
||||||
}elseif($batterieladezustand>$aufdasnachladen && $hyst==true){
|
|
||||||
|
|
||||||
|
|
||||||
$filtered_powersteps = array_filter($array_powersteps, function ($value) {
|
|
||||||
return $value <= 0;
|
|
||||||
});
|
|
||||||
$filtered_powersteps_laden = array_values($filtered_powersteps);
|
|
||||||
$this->SetValue("PowerSteps", json_encode($filtered_powersteps_laden));
|
|
||||||
|
|
||||||
}elseif($batterieladezustand>$minimumentladen){
|
|
||||||
|
|
||||||
$this->SetValue("PowerSteps", json_encode($array_powersteps));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
$filtered_powersteps = array_filter($array_powersteps, function ($value) {
|
|
||||||
return $value >= 0;
|
|
||||||
});
|
|
||||||
$filtered_powersteps_laden = array_values($filtered_powersteps);
|
|
||||||
$this->SetValue("PowerSteps", json_encode($filtered_powersteps_laden));
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
IPS_LogMessage("Batterie", "Im else teil");
|
|
||||||
|
|
||||||
|
|
||||||
if($batterieladezustand>99){
|
|
||||||
IPS_LogMessage("Batterie", "im 1");
|
|
||||||
|
|
||||||
$filtered_powersteps = array_filter($array_powersteps, function ($value) {
|
|
||||||
return $value <= 0;
|
|
||||||
});
|
|
||||||
$filtered_powersteps_laden = array_values($filtered_powersteps);
|
|
||||||
$this->SetValue("PowerSteps", json_encode($filtered_powersteps_laden));
|
|
||||||
|
|
||||||
}elseif($batterieladezustand>$aufdasnachladen && $hyst==false){
|
|
||||||
|
|
||||||
$this->SetValue("PowerSteps", json_encode($array_powersteps));
|
|
||||||
IPS_LogMessage("Batterie", "im 2");
|
|
||||||
|
|
||||||
|
|
||||||
}elseif($batterieladezustand>=$aufdasnachladen && $hyst==true){
|
|
||||||
|
|
||||||
$filtered_powersteps = array_filter($array_powersteps, function ($value) {
|
|
||||||
return $value >= 0;
|
|
||||||
});
|
|
||||||
$filtered_powersteps_laden = array_values($filtered_powersteps);
|
|
||||||
$this->SetValue("PowerSteps", json_encode($filtered_powersteps_laden));
|
|
||||||
|
|
||||||
|
|
||||||
}elseif($batterieladezustand<$aufdasnachladen){
|
|
||||||
|
|
||||||
$dummy_array[] = $this->ReadPropertyInteger("MaxNachladen");
|
|
||||||
$this->SetValue("PowerSteps", json_encode($dummy_array));
|
|
||||||
IPS_LogMessage("Batterie", "im 3");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function CheckIdle($power)
|
|
||||||
{
|
|
||||||
$lastpower = GetValue("Aktuelle_Leistung");
|
|
||||||
if ($lastpower != GetValue("Aktuelle_Leistung")) {
|
|
||||||
$this->SetValue("Idle", false);
|
|
||||||
$this->SetValue(
|
|
||||||
"IdleCounter",
|
|
||||||
$this->ReadPropertyInteger("IdleCounterMax")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// IdleCounter auslesen und verarbeiten
|
|
||||||
$idleCounter = $this->GetValue("IdleCounter");
|
|
||||||
if ($idleCounter > 0) {
|
|
||||||
$this->SetValue("Idle", false);
|
|
||||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Idle", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function ProcessIdleCounter()
|
|
||||||
{
|
|
||||||
// IdleCounter auslesen und verarbeiten
|
|
||||||
$idleCounter = $this->GetValue("IdleCounter");
|
|
||||||
if ($idleCounter > 0) {
|
|
||||||
$this->SetValue("Idle", false);
|
|
||||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
|
||||||
} else {
|
|
||||||
$this->SetValue("Idle", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user