66 lines
2.7 KiB
PHP
66 lines
2.7 KiB
PHP
<?php
|
|
|
|
class Bat_EV_SDL_V4 extends IPSModule
|
|
{
|
|
public function Create()
|
|
{
|
|
parent::Create();
|
|
|
|
// Properties
|
|
$this->RegisterPropertyString("Batteries", "[]");
|
|
$this->RegisterPropertyInteger("SDL_Leistung_Laden", 0); // W
|
|
$this->RegisterPropertyInteger("SDL_Leistung_Entladen", 0); // W
|
|
$this->RegisterPropertyFloat("ReserveHours", 0.5); // h, vorher fix 0.5h
|
|
$this->RegisterPropertyInteger("UpdateInterval", 5); // Sekunden
|
|
$this->RegisterPropertyBoolean("FilterAktiv", true);
|
|
|
|
// Status
|
|
$this->RegisterVariableBoolean("State", "Aktiv", "~Switch", 1);
|
|
$this->EnableAction("State");
|
|
|
|
// Prozentwerte / virtuelle Konten
|
|
$this->RegisterVariableFloat("SDL_Pos", "SDL Energie verfügbar (%)", "", 10);
|
|
$this->RegisterVariableFloat("SoC_EV", "EV Energie verfügbar (%)", "", 11);
|
|
$this->RegisterVariableFloat("SDL_Start_Pos", "SDL Start SoC (%)", "", 35);
|
|
$this->RegisterVariableFloat("EV_Start_Pos", "EV Start SoC (%)", "", 36);
|
|
|
|
// Soll-/Istwerte
|
|
$this->RegisterVariableFloat("Nennleistung_Soll_EV", "Nennleistung Soll EV", "", 2);
|
|
$this->RegisterVariableFloat("Nennleistung_Soll_SDL", "Nennleistung Soll SDL", "", 3);
|
|
$this->RegisterVariableFloat("Aktuelle_Leistung_EV", "Aktuelle Leistung EV", "", 5);
|
|
$this->RegisterVariableFloat("Aktuelle_Leistung_SDL", "Aktuelle Leistung SDL", "", 4);
|
|
|
|
// Maximalleistungen
|
|
$this->RegisterVariableFloat("P_SDL_laden", "P SDL laden max (W)", "", 21);
|
|
$this->RegisterVariableFloat("P_SDL_entladen", "P SDL entladen max (W)", "", 22);
|
|
$this->RegisterVariableInteger("P_EV_laden", "P EV laden max (W)", "", 31);
|
|
$this->RegisterVariableInteger("P_EV_entladen", "P EV entladen max (W)", "", 32);
|
|
|
|
// Reset
|
|
$this->RegisterVariableBoolean("SDL_Reset", "SDL/EV Konto Reset (Start)", "~Switch", 37);
|
|
$this->EnableAction("SDL_Reset");
|
|
|
|
// Debug
|
|
$this->RegisterVariableString("CalcJSON", "Berechnung (JSON)", "", 99);
|
|
|
|
// Timer
|
|
$this->RegisterTimer("UpdateTimer", 0, 'GEF_Update($_IPS["TARGET"]);');
|
|
}
|
|
|
|
public function ApplyChanges()
|
|
{
|
|
parent::ApplyChanges();
|
|
|
|
$intervalSec = (int)$this->ReadPropertyInteger("UpdateInterval");
|
|
$this->SetTimerInterval("UpdateTimer", ($intervalSec > 0) ? $intervalSec * 1000 : 0);
|
|
|
|
// Grenz-/Fensterberechnung nur hier hart neu aufbauen
|
|
$this->BuildBatteryCache(true);
|
|
|
|
// Wenn Konfig neu ist: Integratoren sauber auf Startpunkte setzen
|
|
$this->ResetVirtualAccountsToStartPoint(false);
|
|
|
|
$this->Update();
|
|
}
|
|
|
|
?>
|