Compare commits
4 Commits
cc9c0fbf86
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| dc2d06c1f2 | |||
| 93af0c3735 | |||
| ab859e908e | |||
| d496053a80 |
+381
-379
@@ -1,512 +1,514 @@
|
||||
<?php
|
||||
|
||||
class Batterie 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);
|
||||
$this->RegisterPropertyInteger("AktuelleBatterieleistung", 0); // Initialisierung mit 0
|
||||
$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);
|
||||
$this->RegisterPropertyInteger("AktuelleBatterieleistung", 0);// Initialisierung mit 0
|
||||
$this->RegisterPropertyInteger("Interval", 2); // Recheninterval
|
||||
$this->RegisterVariableInteger("Batteriemanagement_Variabel", "Batteriemanagement_Variabel", "", 0);
|
||||
$this->RegisterVariableInteger("Laden_Entladen", "Laden_Entladen", "", 3);
|
||||
$this->RegisterVariableBoolean("Hysterese", "Hysterese", "", false);
|
||||
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle zugeteilte Leistung", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "Leistungsschritte");
|
||||
$this->RegisterVariableInteger("Batteriemanagement_Variabel","Batteriemanagement_Variabel", "",0);
|
||||
$this->RegisterVariableInteger("Laden_Entladen","Laden_Entladen", "",3);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Priorität Peakshaving");
|
||||
$this->RegisterVariableInteger("PV_Prio", "Priorität PV");
|
||||
$this->RegisterVariableInteger("Power", "Leistung Batterie");
|
||||
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Peakshavingmodus");
|
||||
$this->RegisterVariableInteger("Leistung_Delta", "Leistung Delta", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene Energie", "", 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->RegisterTimer("Timer_Do_UserCalc_Battery", $this->ReadPropertyInteger("Interval") * 1000, "IPS_RequestAction(" . $this->InstanceID . ', "Do_UserCalc", "");');
|
||||
$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);
|
||||
$this->SetTimerInterval("Timer_Do_UserCalc_Battery",$this->ReadPropertyInteger("Interval")*1000);
|
||||
|
||||
$batterietyp = $this->ReadPropertyInteger("Batterietyp");
|
||||
// Batterietypabhängige Variabeln Initialisieren
|
||||
switch ($batterietyp)
|
||||
{
|
||||
case 0: // Herstellerunabhängig
|
||||
$this->MaintainVariable("Goodwe_EntLadeleistung", "Goodwe_EntLadeleistung", VARIABLETYPE_FLOAT, "", 10, false);
|
||||
$this->MaintainVariable("Ladeleistung", "Ladeleistung", VARIABLETYPE_FLOAT, "", 11, false);
|
||||
$this->MaintainVariable("Entladeleistung", "Entladeleistung", VARIABLETYPE_FLOAT, "", 13, false);
|
||||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
$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);
|
||||
break;
|
||||
$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);
|
||||
break;
|
||||
$this->MaintainVariable("Laden_Entladen", "Laden_Entladen", VARIABLETYPE_INTEGER, "", 12, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default, werden alle ausgeschaltet
|
||||
// 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;
|
||||
}
|
||||
//
|
||||
$maxBatVar = $this->ReadPropertyInteger("MaxBatterieleistung");
|
||||
$maxNachVar = $this->ReadPropertyInteger("MaxNachladen");
|
||||
if ($maxBatVar > 0)
|
||||
{
|
||||
$this->RegisterMessage($maxBatVar, VM_UPDATE);
|
||||
}
|
||||
if ($maxNachVar > 0)
|
||||
{
|
||||
$this->RegisterMessage($maxNachVar, VM_UPDATE);
|
||||
break;
|
||||
}
|
||||
|
||||
$maxBatVar = $this->ReadPropertyInteger("MaxBatterieleistung");
|
||||
$maxNachVar = $this->ReadPropertyInteger("MaxNachladen");
|
||||
|
||||
if ($maxBatVar > 0) {
|
||||
$this->RegisterMessage($maxBatVar, VM_UPDATE);
|
||||
}
|
||||
if ($maxNachVar > 0) {
|
||||
$this->RegisterMessage($maxNachVar, VM_UPDATE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Nach aufruf bei anpassung Batteriewerte, sofort Getcurrentdata aufrufen.
|
||||
|
||||
public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
|
||||
{
|
||||
if ($Message !== VM_UPDATE)
|
||||
{
|
||||
return;
|
||||
{
|
||||
if ($Message !== VM_UPDATE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$maxBatVar = $this->ReadPropertyInteger("MaxBatterieleistung");
|
||||
$maxNachVar = $this->ReadPropertyInteger("MaxNachladen");
|
||||
|
||||
if ($SenderID === $maxBatVar || $SenderID === $maxNachVar) {
|
||||
// PowerSteps sofort neu berechnen (mit aktuellem Peak-Status)
|
||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function GeneratePowerSteps()
|
||||
{
|
||||
|
||||
$maxleistung_raw = GetValue($this->ReadPropertyInteger("MaxBatterieleistung"));
|
||||
$nachladen_raw = GetValue($this->ReadPropertyInteger("MaxNachladen"));
|
||||
|
||||
$stepSize = 250; // Grobe Schrittgröße
|
||||
$stepSizeSmall = 50; // Feine Schrittgröße
|
||||
|
||||
// Grenzen auf 50er abrunden (floor)
|
||||
$maxleistung = (int)(floor($maxleistung_raw / $stepSizeSmall) * $stepSizeSmall);
|
||||
$minleistung = (int)(-floor($nachladen_raw / $stepSizeSmall) * $stepSizeSmall); // negativ!
|
||||
|
||||
// Sicherheitscheck: falls Werte komisch sind
|
||||
if ($maxleistung < 0) $maxleistung = 0;
|
||||
if ($minleistung > 0) $minleistung = 0;
|
||||
|
||||
// Grundarray: von min bis max in 250er Schritten
|
||||
$neg = ($minleistung < 0) ? range($minleistung, 0, $stepSize) : [0];
|
||||
$pos = range(0, $maxleistung, $stepSize);
|
||||
|
||||
$array_powersteps = array_values(array_unique(array_merge($neg, $pos)));
|
||||
sort($array_powersteps, SORT_NUMERIC);
|
||||
|
||||
// Zusätzlichen Wert auf 50er abrunden (floor, nicht round!)
|
||||
// (wichtig: floor bei negativen Zahlen geht "weiter runter", daher extra Logik)
|
||||
$closestValue = (int)(floor($additionalValue / $stepSizeSmall) * $stepSizeSmall);
|
||||
|
||||
// Clamp in den Bereich
|
||||
if ($closestValue < $minleistung) $closestValue = $minleistung;
|
||||
if ($closestValue > $maxleistung) $closestValue = $maxleistung;
|
||||
|
||||
// Prüfen ob der Wert im Array existiert (bei 250er Raster oft NICHT)
|
||||
$index = array_search($closestValue, $array_powersteps, true);
|
||||
|
||||
// Wenn nicht vorhanden: an der richtigen Stelle einsortieren
|
||||
if ($index === false) {
|
||||
$index = 0;
|
||||
$count = count($array_powersteps);
|
||||
while ($index < $count && $array_powersteps[$index] < $closestValue) {
|
||||
$index++;
|
||||
}
|
||||
$maxBatVar = $this->ReadPropertyInteger("MaxBatterieleistung");
|
||||
$maxNachVar = $this->ReadPropertyInteger("MaxNachladen");
|
||||
if ($SenderID === $maxBatVar || $SenderID === $maxNachVar)
|
||||
{
|
||||
// PowerSteps sofort neu berechnen (mit aktuellem Peak-Status)
|
||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
||||
// $index ist jetzt Einfügeposition
|
||||
}
|
||||
|
||||
// Feine Werte um closestValue herum (±4 * 50)
|
||||
$newValues = [];
|
||||
for ($i = -4; $i <= 4; $i++) {
|
||||
$v = $closestValue + ($i * $stepSizeSmall);
|
||||
if ($v >= $minleistung && $v <= $maxleistung) {
|
||||
$newValues[] = $v;
|
||||
}
|
||||
}
|
||||
// Aktuelle Leistung setzen lassen, der Manager vorgibt
|
||||
|
||||
// Duplikate vermeiden (falls schon Werte vorhanden sind)
|
||||
$newValues = array_values(array_unique($newValues));
|
||||
|
||||
// Wenn closestValue exakt im Grundarray war: diesen einen ersetzen
|
||||
// sonst: feinwerte einfach an der Einfügestelle einfügen
|
||||
if (array_search($closestValue, $array_powersteps, true) !== false) {
|
||||
$existingIndex = array_search($closestValue, $array_powersteps, true);
|
||||
array_splice($array_powersteps, $existingIndex, 1, $newValues);
|
||||
} else {
|
||||
array_splice($array_powersteps, $index, 0, $newValues);
|
||||
}
|
||||
|
||||
// Am Ende sortieren + Duplikate killen (sicher ist sicher)
|
||||
$array_powersteps = array_values(array_unique($array_powersteps));
|
||||
sort($array_powersteps, SORT_NUMERIC);
|
||||
|
||||
return $array_powersteps;
|
||||
} // Ende Array Steps
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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");
|
||||
//Fallunterscheidung, soll Enelix überhaupt steuern?
|
||||
// Wechselrichter steuert
|
||||
// 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, Herstellerunabhänig im WR Modus
|
||||
|
||||
}
|
||||
elseif ($batterieManagement == 1 && ($batterietyp == 0 || $batterietyp == 3))
|
||||
{
|
||||
$this->SetValue("Entladeleistung", 0);
|
||||
$this->SetValue("Ladeleistung", 0);
|
||||
$this->SetValue("Batteriemanagement_Variabel", 0);
|
||||
return;
|
||||
// Enelix Steuert
|
||||
{
|
||||
|
||||
|
||||
$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);
|
||||
|
||||
}
|
||||
elseif ($batterieManagement == 2 && ($batterietyp == 0 || $batterietyp == 3))
|
||||
{
|
||||
$this->SetValue("Batteriemanagement_Variabel", 1);
|
||||
//Solaredge Symcon Modus
|
||||
|
||||
}
|
||||
elseif ($batterieManagement == 2 && $batterietyp == 2)
|
||||
{
|
||||
$this->SetValue("Batteriemanagement_Variabel", 4);
|
||||
}
|
||||
// Variabeln entsprechend gewältem Batterietyp setzen
|
||||
$batterietyp = $this->ReadPropertyInteger("Batterietyp");
|
||||
if ($batterietyp == 0)
|
||||
{
|
||||
//Herstellerunabhängig
|
||||
if ($this->GetValue("Is_Peak_Shaving") == true)
|
||||
{
|
||||
if ($power >= 0)
|
||||
{
|
||||
$this->SetValue("Ladeleistung", $power);
|
||||
$this->SetValue("Entladeleistung", 0);
|
||||
$this->SetValue("Laden_Entladen", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->SetValue("Entladeleistung", abs($power));
|
||||
$this->SetValue("Ladeleistung", 0);
|
||||
$this->SetValue("Laden_Entladen", 1);
|
||||
}
|
||||
}elseif ($batterieManagement == 2 && $batterietyp == 2) {
|
||||
$this->SetValue("Batteriemanagement_Variabel", 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($power >= 0)
|
||||
{
|
||||
$this->SetValue("Ladeleistung", $power);
|
||||
$this->SetValue("Entladeleistung", 0);
|
||||
$this->SetValue("Laden_Entladen", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->SetValue("Entladeleistung", abs($power));
|
||||
$this->SetValue("Ladeleistung", 0);
|
||||
$this->SetValue("Laden_Entladen", 1);
|
||||
}
|
||||
|
||||
|
||||
$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 == 1)
|
||||
{
|
||||
//Goodwe
|
||||
$this->SetValue("Entladeleistung", 0);
|
||||
$this->SetValue("Ladeleistung", 0);
|
||||
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);
|
||||
}
|
||||
} 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("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
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
}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)
|
||||
{
|
||||
if ($power != $lastPower) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $this->ReadPropertyInteger("IdleCounterMax"));
|
||||
$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));
|
||||
$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)
|
||||
{
|
||||
// Aktuelle Daten ausarbeiten und Berechnen
|
||||
IPS_LogMessage("Batterie", "Currentdata");
|
||||
|
||||
$array_powersteps = $this->GeneratePowerSteps();
|
||||
$aufdasnachladen = $this->ReadPropertyInteger("AufdasNachladen");
|
||||
$minimumentladen = $this->ReadPropertyInteger("MinimumEntladen");
|
||||
$maxleistung = GetValue($this->ReadPropertyInteger("MaxBatterieleistung")); //Ladeleistung
|
||||
$maxentladeleistung = GetValue($this->ReadPropertyInteger("MaxNachladen")); //Entladeleistung
|
||||
$maxleistung = GetValue($this->ReadPropertyInteger("MaxBatterieleistung"));//Ladeleistung
|
||||
$maxentladeleistung = GetValue($this->ReadPropertyInteger("MaxNachladen"));//Entladeleistung
|
||||
$dummy_array = [];
|
||||
$batterieladezustand = GetValue($this->ReadPropertyInteger("Batterieladezustand"));
|
||||
$filtered_powersteps_entladen = [];
|
||||
if ($this->ReadPropertyInteger("Batteriemanagement") == 1)
|
||||
{
|
||||
if ($this->ReadPropertyInteger("Batteriemanagement") == 1) {
|
||||
$dummy_array[] = 0;
|
||||
return $this->SetValue("PowerSteps", json_encode($dummy_array));
|
||||
}
|
||||
|
||||
|
||||
$netzbezug = GetValue($this->ReadPropertyInteger("Netzbezug"));
|
||||
$bat_leistung = GetValue($this->ReadPropertyInteger("AktuelleBatterieleistung"));
|
||||
if ($Peak && $netzbezug > 0)
|
||||
{
|
||||
$netzbezug = - min($netzbezug, $maxentladeleistung) + $bat_leistung;
|
||||
|
||||
/*
|
||||
if (abs($netzbezug) > $maxentladeleistung) {
|
||||
//$netzbezug = $maxentladeleistung * (-1);
|
||||
$netzbezug = $netzbezug * (-1);
|
||||
}*/
|
||||
|
||||
|
||||
if ($Peak && $netzbezug > 0) {
|
||||
$netzbezug = -min($netzbezug, $maxentladeleistung) + $bat_leistung;
|
||||
}
|
||||
if ($batterieladezustand > 5 + $aufdasnachladen)
|
||||
{
|
||||
|
||||
if($batterieladezustand>(5+$aufdasnachladen)){
|
||||
|
||||
$this->SetValue("Hysterese", false);
|
||||
}
|
||||
elseif ($batterieladezustand <= $aufdasnachladen)
|
||||
{
|
||||
|
||||
}elseif($batterieladezustand<=$aufdasnachladen){
|
||||
$this->SetValue("Hysterese", true);
|
||||
}
|
||||
|
||||
$hyst = $this->GetValue("Hysterese");
|
||||
if ($Peak)
|
||||
{
|
||||
if ($batterieladezustand > $aufdasnachladen && $hyst == false)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}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));
|
||||
}
|
||||
elseif ($batterieladezustand > $minimumentladen)
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode($array_powersteps));
|
||||
}
|
||||
else
|
||||
{
|
||||
$filtered_powersteps = array_filter($array_powersteps, function ($value)
|
||||
{
|
||||
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
|
||||
{
|
||||
if ($batterieladezustand > 99)
|
||||
{
|
||||
$filtered_powersteps = array_filter($array_powersteps, function ($value)
|
||||
{
|
||||
|
||||
}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)
|
||||
{
|
||||
|
||||
}elseif($batterieladezustand>$aufdasnachladen && $hyst==false){
|
||||
|
||||
$this->SetValue("PowerSteps", json_encode($array_powersteps));
|
||||
}
|
||||
elseif ($batterieladezustand >= $aufdasnachladen && $hyst == true)
|
||||
{
|
||||
$filtered_powersteps = array_filter($array_powersteps, function ($value)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
|
||||
}elseif($batterieladezustand<$aufdasnachladen){
|
||||
|
||||
//$dummy_array[] = GetValue($this->ReadPropertyInteger("MaxNachladen"));
|
||||
$dummy_array[] = GetValue($this->ReadPropertyInteger("MaxBatterieleistung"));
|
||||
$this->SetValue("PowerSteps", json_encode($dummy_array));
|
||||
IPS_LogMessage("Batterie", "im 3");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// Ab hier Hilfsfunktionen
|
||||
private function GeneratePowerSteps()
|
||||
{
|
||||
// Hilfsfunktion um die Möglichen Powersteps zu generieren
|
||||
$maxleistung_raw = GetValue($this->ReadPropertyInteger("MaxBatterieleistung"));
|
||||
$nachladen_raw = GetValue($this->ReadPropertyInteger("MaxNachladen"));
|
||||
$stepSize = 250; // Grobe Schrittgröße
|
||||
$stepSizeSmall = 50; // Feine Schrittgröße
|
||||
// Grenzen auf 50er abrunden (floor)
|
||||
$maxleistung = (int)(floor($maxleistung_raw / $stepSizeSmall) * $stepSizeSmall);
|
||||
$minleistung = (int)(-floor($nachladen_raw / $stepSizeSmall) * $stepSizeSmall); // negativ!
|
||||
// Sicherheitscheck: falls Werte komisch sind
|
||||
if ($maxleistung < 0)
|
||||
{
|
||||
$maxleistung = 0;
|
||||
}
|
||||
if ($minleistung > 0)
|
||||
{
|
||||
$minleistung = 0;
|
||||
}
|
||||
// Grundarray: von min bis max in 250er Schritten
|
||||
$neg = $minleistung < 0 ? range($minleistung, 0, $stepSize) : [0];
|
||||
$pos = range(0, $maxleistung, $stepSize);
|
||||
$array_powersteps = array_values(array_unique(array_merge($neg, $pos)));
|
||||
sort($array_powersteps, SORT_NUMERIC);
|
||||
// Zusätzlichen Wert auf 50er abrunden
|
||||
$closestValue = (int)(floor($additionalValue / $stepSizeSmall) * $stepSizeSmall);
|
||||
// Clamp in den Bereich
|
||||
if ($closestValue < $minleistung)
|
||||
{
|
||||
$closestValue = $minleistung;
|
||||
}
|
||||
if ($closestValue > $maxleistung)
|
||||
{
|
||||
$closestValue = $maxleistung;
|
||||
}
|
||||
// Prüfen ob der Wert im Array existiert (bei 250er Raster oft NICHT)
|
||||
$index = array_search($closestValue, $array_powersteps, true);
|
||||
// Wenn nicht vorhanden: an der richtigen Stelle einsortieren
|
||||
if ($index === false)
|
||||
{
|
||||
$index = 0;
|
||||
$count = count($array_powersteps);
|
||||
while ($index < $count && $array_powersteps[$index] < $closestValue)
|
||||
{
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
// Feine Werte um closestValue herum (±4 * 50)
|
||||
$newValues = [];
|
||||
for ($i = - 4;$i <= 4;$i++)
|
||||
{
|
||||
$v = $closestValue + $i * $stepSizeSmall;
|
||||
if ($v >= $minleistung && $v <= $maxleistung)
|
||||
{
|
||||
$newValues[] = $v;
|
||||
}
|
||||
}
|
||||
// Duplikate vermeiden (falls schon Werte vorhanden sind)
|
||||
$newValues = array_values(array_unique($newValues));
|
||||
// Wenn closestValue exakt im Grundarray war: diesen einen ersetzen
|
||||
// sonst: feinwerte einfach an der Einfügestelle einfügen
|
||||
if (array_search($closestValue, $array_powersteps, true) !== false)
|
||||
{
|
||||
$existingIndex = array_search($closestValue, $array_powersteps, true);
|
||||
array_splice($array_powersteps, $existingIndex, 1, $newValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_splice($array_powersteps, $index, 0, $newValues);
|
||||
}
|
||||
// Am Ende sortieren
|
||||
$array_powersteps = array_values(array_unique($array_powersteps));
|
||||
sort($array_powersteps, SORT_NUMERIC);
|
||||
return $array_powersteps;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private function CheckIdle($power)
|
||||
{
|
||||
// Hilfsfunktion zum Prüfen ob die Batterie schon wieder Leistung verändern kann
|
||||
$lastpower = GetValue("Aktuelle_Leistung");
|
||||
if ($lastpower != GetValue("Aktuelle_Leistung"))
|
||||
{
|
||||
if ($lastpower != GetValue("Aktuelle_Leistung")) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $this->ReadPropertyInteger("IdleCounterMax"));
|
||||
$this->SetValue(
|
||||
"IdleCounter",
|
||||
$this->ReadPropertyInteger("IdleCounterMax")
|
||||
);
|
||||
}
|
||||
// IdleCounter auslesen und verarbeiten
|
||||
$idleCounter = $this->GetValue("IdleCounter");
|
||||
if ($idleCounter > 0)
|
||||
{
|
||||
if ($idleCounter > 0) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function ProcessIdleCounter()
|
||||
{
|
||||
// IdleCounter auslesen und verarbeiten
|
||||
$idleCounter = $this->GetValue("IdleCounter");
|
||||
if ($idleCounter > 0)
|
||||
{
|
||||
if ($idleCounter > 0) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
+4
-4
@@ -183,9 +183,9 @@ class Manager extends IPSModule
|
||||
// Wenn die Prio geleich ist, sortiere danach welcher verbraucher bisher am wenigsten Energie bekommen hat.
|
||||
if ($a[$primaryKey] == $b[$primaryKey])
|
||||
{
|
||||
return round($a["Bezogene_Energie"] / 2000) <= > round($b["Bezogene_Energie"] / 2000);
|
||||
return round($a["Bezogene_Energie"] / 2000) <=> round($b["Bezogene_Energie"] / 2000);
|
||||
}
|
||||
return $a[$primaryKey] <= > $b[$primaryKey];
|
||||
return $a[$primaryKey] <=> $b[$primaryKey];
|
||||
});
|
||||
// Primärschlüssel für die Priorität basierend auf dem Parameter auswählen (für sortierung in gruppen anschliessend)
|
||||
$priorityKey = $Is_Peak_Shaving ? "Sperre_Prio" : "PV_Prio";
|
||||
@@ -299,7 +299,7 @@ class Manager extends IPSModule
|
||||
// Sortiere die Schritte nach Größe
|
||||
usort($allSteps, function ($a, $b)
|
||||
{
|
||||
return $a["step"] <= > $b["step"];
|
||||
return $a["step"] <=> $b["step"];
|
||||
});
|
||||
//if remaining power >0
|
||||
// Iteriere durch alle Schritte
|
||||
@@ -361,7 +361,7 @@ class Manager extends IPSModule
|
||||
// Sortiere die Schritte nach Größe
|
||||
usort($allSteps, function ($a, $b)
|
||||
{
|
||||
return $a["step"] <= > $b["step"];
|
||||
return $a["step"] <=> $b["step"];
|
||||
});
|
||||
$remainingPower = $remainingPower * -1;
|
||||
// Iteriere durch alle Schritte
|
||||
|
||||
@@ -5,7 +5,7 @@ Es verteilt elektrische Leistung auf mehrere Verbraucher (z. B. Elektroauto-Lade
|
||||
|
||||
- **Einzelhaus-Anschlüsse**
|
||||
- **ZEV/V-ZEV-Verbundsysteme**
|
||||
- **Lastenmanagement-Gemeinschaften (LEG)**
|
||||
- **Lokale Elektriziäts-Gemeinschaften (LEG)**
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
# Enelix-Verbrauchermodul 1-Stufig
|
||||
|
||||
Dieses Modul integriert einfache, nicht-modulierende Verbraucher (Ein/Aus) wie klassische Heizstäbe, Wärmepumpen oder einfache Boiler in das Belevo Energiemanagement-System (Enelix). Es schaltet den Verbraucher basierend auf PV-Überschuss, Peak-Shaving-Vorgaben und einer garantierten Mindestlaufzeit während der Nachtstunden.
|
||||
|
||||
---
|
||||
|
||||
## Inhaltsverzeichnis
|
||||
|
||||
1. [Funktionsumfang](#1-funktionsumfang)
|
||||
2. [Voraussetzungen](#2-voraussetzungen)
|
||||
3. [Installation](#3-installation)
|
||||
4. [Instanz anlegen & Konfiguration](#4-instanz-anlegen--konfiguration)
|
||||
5. [Statusvariablen](#5-statusvariablen)
|
||||
6. [WebFront / Bedienung](#6-webfront--bedienung)
|
||||
7. [Mapping auf Code-Komponenten](#7-mapping-auf-code-komponenten)
|
||||
8. [Zukünftige Erweiterungen](#8-zukünftige-erweiterungen)
|
||||
|
||||
---
|
||||
|
||||
## 1. Funktionsumfang
|
||||
|
||||
- **1-Stufige Steuerung:** Bietet dem Enelix-Manager exakt zwei Zustände an: `0` (Aus) oder die definierte `Leistung` (Ein).
|
||||
- **Direkte Aktor-Steuerung:** Schaltet eine hinterlegte IP-Symcon Variable (`Schaltkontakt1`) direkt auf `true` oder `false`.
|
||||
- **Nacht-Mindestlaufzeit:** Sichert ab, dass der Verbraucher nachts (22:00 bis 07:00 Uhr) eine definierte Mindestlaufzeit (`Mindesttlaufzeit`) erreicht. Wird diese nicht über PV-Überschuss am Tag erreicht, erzwingt das Modul die Einschaltung (Netzbezug).
|
||||
- **Taktschutz (Verzögerungslogik):** Die Einstellung `Zeit_Zwischen_Zustandswechseln` blockiert für x Minuten nach einem Schaltvorgang weitere Leistungsänderungen, um das Relais oder den angeschlossenen Verbraucher vor schnellem Takten zu schützen.
|
||||
- **Manager-Sperrlogik (Idle):** Ein Zähler (`IdleCounterMax`) verzögert die Rückmeldung an den Manager, bis der Verbraucher seinen Status stabil gewechselt hat.
|
||||
|
||||
---
|
||||
|
||||
## 2. Voraussetzungen
|
||||
|
||||
- IP-Symcon **≥ 8.0**
|
||||
- Modul-URL: `https://git.belevo.ch/dh/enelix.git`
|
||||
- Vorhandener und eingerichteter Enelix Manager.
|
||||
- Physischer Schaltaktor (z.B. Shelly, KNX Schaltaktor) zur Steuerung des Verbrauchers.
|
||||
|
||||
---
|
||||
|
||||
## 3. Installation
|
||||
|
||||
1. In IP-Symcon **Module Control** öffnen.
|
||||
2. **Hinzufügen → Git-Repository**.
|
||||
3. URL eingeben und **Installieren**.
|
||||
4. IP-Symcon neu starten.
|
||||
|
||||
---
|
||||
|
||||
## 4. Instanz anlegen & Konfiguration
|
||||
|
||||
### 4.1 Instanz anlegen
|
||||
|
||||
- Rechtsklick **Instanzen** → **Instanz hinzufügen**
|
||||
- Filter: **Belevo**
|
||||
- Auswahl: **Verbraucher 1-Stufig**
|
||||
|
||||
### 4.2 Properties
|
||||
|
||||
| Name | Typ | Beschreibung |
|
||||
|---|---|---|
|
||||
| **BoilerLeistung** | NumberSpinner | Leistungsaufnahme des Verbrauchers unter Volllast in Watt (z.B. 6000). |
|
||||
| **Mindesttlaufzeit** | NumberSpinner | Garantierte Mindestlaufzeit in Stunden, die nachts erreicht werden muss. |
|
||||
| **Zeit_Zwischen_Zustandswechseln**| NumberSpinner | Taktschutz: Sperrzeit in Minuten zwischen zwei Schaltvorgängen. |
|
||||
| **Schaltkontakt1** | SelectVariable | Objekt-ID der Variable, die den physischen Aktor schaltet (Boolean). |
|
||||
| **Interval** | NumberSpinner | Berechnungsintervall in Sekunden (Standard: 5). |
|
||||
| **IdleCounterMax** | NumberSpinner | Anzahl Intervall-Zyklen zwischen zwei Schaltvorgängen für die Manager-Freigabe. |
|
||||
|
||||
---
|
||||
|
||||
## 5. Statusvariablen
|
||||
|
||||
| Ident | Typ | Beschreibung |
|
||||
|---|---|---|
|
||||
| **IstNacht** | Boolean | Zeigt an, ob aktuell der Nacht-Modus (22:00 - 07:00) aktiv ist. |
|
||||
| **DailyOnTime** | Integer | Zähler für die Laufzeit im aktuellen Zyklus (wird zu Beginn der Nacht genullt). |
|
||||
| **IsTimerActive** | Boolean | Status des Taktschutzes (`true` = Statuswechsel aktuell blockiert). |
|
||||
| **Aktuelle_Leistung** | Integer | Die aktuell vom Manager zugewiesene Soll-Leistung (0 oder `BoilerLeistung`). |
|
||||
| **PowerSteps** | String | JSON-Array der dem Manager angebotenen Schritte (z.B. `[0, 6000]`). |
|
||||
| **Idle** | Boolean | Status der Manager-Sperrzeit (`true` = bereit für neue Werte, `false` = gesperrt). |
|
||||
| **Sperre_Prio** | Integer | Priorität für die Leistungszuteilung im Peak-Shaving-Modus. |
|
||||
| **PV_Prio** | Integer | Priorität für die Leistungszuteilung im Solarlade-Modus. |
|
||||
| **Bezogene_Energie** | Float | Rechnerisch aufsummierte Energie (Leistung × Zeit). |
|
||||
| **Is_Peak_Shaving** | Boolean | Vom Manager übermittelter aktueller Betriebsmodus. |
|
||||
|
||||
---
|
||||
|
||||
## 6. WebFront / Bedienung
|
||||
|
||||
Im WebFront dient das Modul hauptsächlich der Visualisierung und der Prioritäten-Steuerung:
|
||||
- Überwachung, ob der Nacht-Modus (`IstNacht`) aktiv ist und wie lange der Verbraucher bereits lief (`DailyOnTime`).
|
||||
- Kontrolle der aktuell zugewiesenen Leistung (`Aktuelle_Leistung`) und des Taktschutzes (`IsTimerActive`).
|
||||
- Anpassung der Steuerungsprioritäten (`PV_Prio`, `Sperre_Prio`).
|
||||
|
||||
---
|
||||
|
||||
## 7. Mapping auf Code-Komponenten
|
||||
|
||||
| Komponente | Funktion im Code (`module.php`) |
|
||||
|---|---|
|
||||
| **Timer-Registrierung** | `ApplyChanges()` setzt den Haupt-Berechnungstimer `Timer_Do_UserCalc_Verb`. |
|
||||
| **Nacht-Erkennung** | `ist_nachts()` prüft hardcodiert die Zeitspanne 22:00 bis 07:00 Uhr. |
|
||||
| **Laufzeit-Überwachung**| `GetCurrentData()` nullt `DailyOnTime` beim Wechsel von Tag zu Nacht. Die Laufzeit wird in `SetAktuelle_Leistung()` pro Intervall hochgezählt. |
|
||||
| **Betriebslogik** | `GetCurrentData($Peak)` baut die `PowerSteps`. Ist es Nacht und die Mindestlaufzeit nicht erreicht, wird `[BoilerLeistung]` erzwungen. Am Tag oder nach Erreichen der Zeit wird `[0, BoilerLeistung]` für Überschussladen angeboten. |
|
||||
| **Taktschutz** | `SetTimerOn()` und `ResetPowerSteps()` blockieren die Modifikation der `PowerSteps` für die Dauer von `Zeit_Zwischen_Zustandswechseln`. |
|
||||
| **Aktorsteuerung** | `SetAktuelle_Leistung($power)` vergleicht die geforderte Leistung mit `BoilerLeistung` und setzt die Variable in `Schaltkontakt1` entsprechend auf `true` oder `false`. |
|
||||
|
||||
---
|
||||
|
||||
## 8. Zukünftige Erweiterungen
|
||||
|
||||
- **Dynamische Nachtzeiten/Stromtarife:** Konfigurierbare Start- und Endzeiten für den Nacht- bzw. Niedertarifzeitraum über die Modul-Properties (statt hardcodiert 22:00 bis 07:00 Uhr).
|
||||
- **Externer Hardware-Status:** Rücklesefunktion des Aktors, um manuelle Schaltungen am Relais in der `DailyOnTime` und Energieberechnung zu berücksichtigen.
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Einstellungen für einstufigen Verbruacher Ein-Aus"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "IdleCounterMax",
|
||||
"caption": "Zyklen zwischen zwei Leistungsänderungen (Multipliziert sich mit Interval)",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Interval",
|
||||
"caption": "Intervall Neuberechnung der Werte Erst für spätere Versionen, aktuell auf 5 lassen!",
|
||||
"suffix": "Sekunden"
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Mindesttlaufzeit",
|
||||
"caption": "Mindestlaufzeit des Verbruachers wärend eines Tages",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Zeit_Zwischen_Zustandswechseln",
|
||||
"caption": "Mindestlaufzeit des Verbrauchers bei Lastschaltung",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "BoilerLeistung",
|
||||
"caption": "Leistung des Verbrauchers",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Schaltkontakt1",
|
||||
"caption": "Zu schaltenden Kontakt",
|
||||
"test": true
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{5A156BE6-30FE-55AC-A832-7F80BF043C8C}",
|
||||
"name": "Verbraucher_1_Stufig",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": ["Verbraucher 1-Stufig"],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
class Verbraucher_1_Stufig extends IPSModule
|
||||
{
|
||||
private $timerID;
|
||||
|
||||
public function Create()
|
||||
{
|
||||
parent::Create();
|
||||
|
||||
// Verbraucherspezifische Properties
|
||||
$this->RegisterPropertyInteger("BoilerLeistung", 6000); // Standardwert für Volllast
|
||||
$this->RegisterPropertyInteger("Mindesttlaufzeit", 4); // Standardwert für Volllast
|
||||
$this->RegisterPropertyInteger("Zeit_Zwischen_Zustandswechseln", 1);
|
||||
$this->RegisterPropertyInteger("Schaltkontakt1", 0);
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
// Verbraucherspezifische Variabeln
|
||||
$this->RegisterVariableBoolean("IstNacht", "IstNacht", "", 0);
|
||||
$this->RegisterVariableInteger("DailyOnTime", "DailyOnTime", "", 0);
|
||||
$this->RegisterVariableBoolean("IsTimerActive", "IsTimerActive", "", 0);
|
||||
|
||||
// Verbraucherspezifischer Timer
|
||||
$this->SetValue("IsTimerActive", false);
|
||||
$this->RegisterTimer("ZustandswechselTimer", 0, "IPS_RequestAction(" . $this->InstanceID . ', "ResetPowerSteps", "");');
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
$this->RegisterVariableInteger("Power", "Power");
|
||||
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving");
|
||||
$this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 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_Verb", $this->ReadPropertyInteger("Interval") * 1000, "IPS_RequestAction(" . $this->InstanceID . ', "Do_UserCalc", "");');
|
||||
|
||||
}
|
||||
|
||||
public function ApplyChanges()
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
$this->SetTimerInterval("Timer_Do_UserCalc_Verb", $this->ReadPropertyInteger("Interval") * 1000);
|
||||
|
||||
}
|
||||
|
||||
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 "ResetPowerSteps":
|
||||
$this->ResetPowerSteps($Value);
|
||||
break;
|
||||
|
||||
case "Do_UserCalc":
|
||||
$this->SetAktuelle_Leistung($this->GetValue("Power"));
|
||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Methode zum Setzen der PowerSteps und Timer starten um zu hohes Takten zu unterbinden
|
||||
public function SetTimerOn()
|
||||
{
|
||||
// Timer setzen, der nach "Zeit_Zwischen_Zustandswechseln" abläuft
|
||||
$zeitZwischenZustandswechseln = $this->ReadPropertyInteger("Zeit_Zwischen_Zustandswechseln");
|
||||
$this->SetTimerInterval("ZustandswechselTimer", $zeitZwischenZustandswechseln * 60000); // Timer in Millisekunden
|
||||
IPS_LogMessage("Verbraucher", "In Set Methode");
|
||||
|
||||
// Timer-Status auf true setzen
|
||||
$this->SetValue("IsTimerActive", true);
|
||||
}
|
||||
|
||||
// Methode zum Zurücksetzen von PowerSteps nach Ablauf des Timers
|
||||
public function ResetPowerSteps()
|
||||
{
|
||||
// PowerSteps wieder auf den ursprünglichen Zustand setzen (wie vorherige Funktionalität)
|
||||
$this->SetValue("PowerSteps", json_encode([$this->GetValue("Aktuelle_Leistung") ]));
|
||||
|
||||
// Timer stoppen
|
||||
$this->SetTimerInterval("ZustandswechselTimer", 0);
|
||||
|
||||
// Timer-Status auf false setzen
|
||||
$this->SetValue("IsTimerActive", false);
|
||||
}
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetAktuelle_Leistung(float $power)
|
||||
{
|
||||
$this->CheckIdle($power);
|
||||
if ($this->GetValue("Aktuelle_Leistung") != $power)
|
||||
{
|
||||
$this->SetTimerOn();
|
||||
}
|
||||
$this->SetValue("Aktuelle_Leistung", $power);
|
||||
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung") * ($this->ReadPropertyInteger("Interval") / 3600))));
|
||||
|
||||
$boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung");
|
||||
$schaltkontaktID = $this->ReadPropertyInteger("Schaltkontakt1");
|
||||
|
||||
if ($power == $boilerLeistung)
|
||||
{
|
||||
$schaltkontaktStatus = true;
|
||||
}
|
||||
elseif ($power == 0)
|
||||
{
|
||||
$schaltkontaktStatus = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Keine Änderung, wenn power nicht 0 oder boilerLeistung entspricht
|
||||
return;
|
||||
}
|
||||
|
||||
$currentStatus = GetValue($this->ReadPropertyInteger("Schaltkontakt1"));
|
||||
|
||||
// Schaltkontaktstatus ändern
|
||||
SetValue($this->ReadPropertyInteger("Schaltkontakt1") , $schaltkontaktStatus);
|
||||
|
||||
if ($schaltkontaktStatus)
|
||||
{
|
||||
$this->SetValue("DailyOnTime", $this->GetValue("DailyOnTime") + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Methode zum Abrufen der aktuellen Daten
|
||||
public function GetCurrentData(bool $Peak)
|
||||
{
|
||||
$IstNacht = $this->GetValue("IstNacht");
|
||||
$NeuesIstNacht = $this->ist_nachts();
|
||||
|
||||
if ($IstNacht == true && $NeuesIstNacht == false)
|
||||
{
|
||||
$this->SetValue("DailyOnTime", 0);
|
||||
}
|
||||
|
||||
$this->SetValue("IstNacht", $NeuesIstNacht);
|
||||
|
||||
$DailyOnTime = $this->GetValue("DailyOnTime");
|
||||
$Mindestlaufzeit = $this->ReadPropertyInteger("Mindesttlaufzeit") * 60 * 12;
|
||||
|
||||
// Überprüfen, ob der Timer aktiv ist
|
||||
if ($this->GetValue("IsTimerActive"))
|
||||
{
|
||||
// Timer ist aktiv, PowerSteps setzen
|
||||
$this->SetValue("PowerSteps", json_encode([$this->GetValue("Aktuelle_Leistung") ]));
|
||||
}
|
||||
// Wenn Nacht und Mindestlaufzeit nicht erreicht ist
|
||||
elseif ($NeuesIstNacht && $DailyOnTime < $Mindestlaufzeit)
|
||||
{
|
||||
if ($Peak)
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung") , ]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([$this->ReadPropertyInteger("BoilerLeistung") ]));
|
||||
}
|
||||
}
|
||||
// Andernfalls
|
||||
else
|
||||
{
|
||||
if ($Peak)
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([0, $this->ReadPropertyInteger("BoilerLeistung") , ]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CheckIdle($power)
|
||||
{
|
||||
$lastpower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
if ($lastpower != $power)
|
||||
{
|
||||
$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 ist_nachts()
|
||||
{
|
||||
date_default_timezone_set("Europe/Berlin"); // Setze hier deine Zeitzone
|
||||
$aktuelle_zeit = strtotime(date("H:i")); // Aktuelle Zeit in Stunden und Minuten umwandeln
|
||||
$start_nacht = strtotime("22:00"); // Startzeit der Nacht (22 Uhr)
|
||||
$ende_nacht = strtotime("07:00"); // Endzeit der Nacht (7 Uhr)
|
||||
if ($aktuelle_zeit >= $start_nacht || $aktuelle_zeit < $ende_nacht)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,121 @@
|
||||
# Enelix-Verbrauchermodul Warmwasser (Boiler)
|
||||
|
||||
Dieses Modul integriert elektrische Warmwasserboiler mit geschalteten Heizstäben mit variablen Heizstufen in das Belevo Energiemanagement-System (Enelix). Es steuert die Leistungsstufen dynamisch nach PV-Überschuss, Peak-Shaving-Vorgaben, Temperaturvorgaben sowie Zeitplänen und integriert einen automatischen Legionellenschutz.
|
||||
|
||||
---
|
||||
|
||||
## Inhaltsverzeichnis
|
||||
|
||||
1. [Funktionsumfang](#1-funktionsumfang)
|
||||
2. [Voraussetzungen](#2-voraussetzungen)
|
||||
3. [Installation](#3-installation)
|
||||
4. [Instanz anlegen & Konfiguration](#4-instanz-anlegen--konfiguration)
|
||||
5. [Statusvariablen & Profile](#5-statusvariablen--profile)
|
||||
6. [WebFront / Bedienung](#6-webfront--bedienung)
|
||||
7. [Mapping auf Code-Komponenten](#7-mapping-auf-code-komponenten)
|
||||
8. [Zukünftige Erweiterungen](#8-zukünftige-erweiterungen)
|
||||
|
||||
---
|
||||
|
||||
## 1. Funktionsumfang
|
||||
|
||||
- **Stufensteuerung (LeistungsStufen):** Definition beliebiger Leistungsschritte (Watt) mit direkter Zuweisung von IP-Symcon Schaltkontakten (Variablen-IDs).
|
||||
- **Temperaturüberwachung & Glättung:** Auswertung eines Temperaturfühlers mit optionaler PT1-Glättung (Tiefpassfilter über `ZeitKonstante`), um Messrauschen zu minimieren.
|
||||
- **Betriebsmodi (PV vs. Peak):**
|
||||
- *Peak-Shaving:* Heizen nur bei Unterschreitung der `Mindesttemperatur` (Zwangsaufheizung), optional auch ganz deaktivierbar.
|
||||
- *Solarladen:* Stufenweise Aufheizung bis zur `Maximaltemperatur` mit überschüssiger PV-Leistung. Fällt die Temperatur unter `Mindesttemperatur`, wird mit maximaler Leistung geheizt.
|
||||
- **Legionellenschutz:** Ein interner Zähler (`LegioCounter`) überwacht die Zeit seit der letzten Hochtemperaturphase. Wird ein Grenzwert überschritten, wird die `Maximaltemperatur` (bzw. später auch die `Mindesttemperatur` im Nachtbetrieb) automatisch auf die `Legionellentemperatur` angehoben.
|
||||
- **Vorausschauende Zeitpläne (Landwirtschaft):** Über einen JSON-Zeitplan können Zieltemperaturen zu bestimmten Uhrzeiten definiert werden. Das Modul berechnet über die physikalische Wärmekapazität (Volumen, Delta-T) vorausschauend, ob und wann die Heizung aktiviert werden muss, um das Ziel rechtzeitig zu erreichen.
|
||||
- **Taktschutz (Idle-Logik):** Ein einstellbarer Zähler (`IdleCounterMax`) verhindert ein zu häufiges Schalten der Heizstäbe sowie eine Mindestlaufzeit.
|
||||
|
||||
---
|
||||
|
||||
## 2. Voraussetzungen
|
||||
|
||||
- IP-Symcon **≥ 8.0**
|
||||
- Modul-URL: `https://git.belevo.ch/dh/enelix.git`
|
||||
- Vorhandener und eingerichteter Enelix Manager.
|
||||
- Physische Schaltaktoren für die Boiler-Heizstäbe.
|
||||
- Temperaturfühler im Boiler mit Fühlerwert als Variable in Symcon.
|
||||
|
||||
---
|
||||
|
||||
## 3. Installation
|
||||
|
||||
1. In IP-Symcon **Module Control** öffnen.
|
||||
2. **Hinzufügen → Git-Repository**.
|
||||
3. URL eingeben und **Installieren**.
|
||||
4. IP-Symcon neu starten.
|
||||
|
||||
---
|
||||
|
||||
## 4. Instanz anlegen & Konfiguration
|
||||
|
||||
### 4.1 Instanz anlegen
|
||||
|
||||
- Rechtsklick **Instanzen** → **Instanz hinzufügen**
|
||||
- Filter: **Belevo**
|
||||
- Auswahl: **Warmwasser (Verbraucher)**
|
||||
|
||||
### 4.2 Properties
|
||||
|
||||
| Name | Typ | Beschreibung |
|
||||
|---|---|---|
|
||||
| **LeistungsStufen** | String (JSON) | Konfiguration der Leistungsschritte und der verknüpften Aktor-Variablen-IDs. |
|
||||
| **Boilerfuehler_PT1** | SelectVariable | Variablen-ID des Hardware-Temperaturfühlers. |
|
||||
| **Boilertemperatur_glätten** | Boolean | Aktiviert das Software-Tiefpassfilter für den Fühlerwert. |
|
||||
| **ZeitKonstante** | NumberSpinner | Zeitkonstante für die Temperatur-Glättung. |
|
||||
| **Boilervolumen** | NumberSpinner | Boilervolumen in Litern (Basis für die thermodynamische Berechnung im Zeitplan). |
|
||||
| **Zeitplan** | String (JSON) | Optionaler Zeitplan für Zieltemperaturen (Format: `[{"Uhrzeit":"06:00","Solltemperatur":55}]`). |
|
||||
| **Interval** | NumberSpinner | Berechnungsintervall in Sekunden. |
|
||||
| **IdleCounterMax** | NumberSpinner | Anzahl Intervall-Zyklen zwischen zwei Schaltvorgängen (Verzögerung). |
|
||||
|
||||
---
|
||||
|
||||
## 5. Statusvariablen & Profile
|
||||
|
||||
| Ident | Typ | Beschreibung |
|
||||
|---|---|---|
|
||||
| **Mindesttemperatur** | Integer | Unteres Limit. Wird dieser Wert unterschritten, wird immer geheizt (Netzbezug). |
|
||||
| **Maximaltemperatur** | Integer | Oberes Limit für PV-Überschussladung. |
|
||||
| **Legionellentemperatur**| Integer | Zieltemperatur für den automatischen Legionellenzyklus (z.B. 65°C). |
|
||||
| **Boilertemperatur** | Float | Aktuelle, ggf. geglättete Ist-Temperatur des Boilers. |
|
||||
| **LegioCounter** | Integer | Interner Zähler für die Laufzeit seit der letzten Legionellen-Desinfektion. |
|
||||
| **Aktuelle_Leistung** | Integer | Die aktuell vom Manager zugewiesene Soll-Leistung in Watt. |
|
||||
| **PowerSteps** | String | JSON-Array der dem Manager aktuell angebotenen möglichen Leistungsschritte. |
|
||||
| **Idle** | Boolean | Status der Sperrzeit (`true` = bereit für neue Werte, `false` = gesperrt). |
|
||||
| **Sperre_Prio** | Integer | Priorität für die Leistungszuteilung im Peak-Shaving-Modus. |
|
||||
| **PV_Prio** | Integer | Priorität für die Leistungszuteilung im Solarlade-Modus. |
|
||||
| **Bezogene_Energie** | Float | Rechnerisch aufsummierte Energie (Leistung × Zeit). |
|
||||
| **Is_Peak_Shaving** | Boolean | Vom Manager übermittelter aktueller Betriebsmodus. |
|
||||
|
||||
Für alle Sollwerte wird jeweils eine Hysterese von 5 °C miteingehalten.
|
||||
---
|
||||
|
||||
## 6. WebFront / Bedienung
|
||||
|
||||
Im WebFront dient die Instanz zur Kontrolle und Anpassung der Temperaturvorgaben:
|
||||
- Einstellen von `Mindesttemperatur`, `Maximaltemperatur` und `Legionellentemperatur`.
|
||||
- Überwachung der aktuellen `Boilertemperatur`.
|
||||
- Visualisierung der vom Manager freigegebenen `Aktuelle_Leistung`.
|
||||
- Die Anpassung von Prioritäten (`PV_Prio`, `Sperre_Prio`).
|
||||
|
||||
---
|
||||
|
||||
## 7. Mapping auf Code-Komponenten
|
||||
|
||||
| Komponente | Funktion im Code (`module.php`) |
|
||||
|---|---|
|
||||
| **Datenaufbereitung** | `LadeUndSortiereLeistungen()` decodiert das JSON-Array `LeistungsStufen` und sortiert die Watt-Werte aufsteigend. |
|
||||
| **Temperaturberechnung**| `GetCurrentData()` liest den PT1-Fühler aus und berechnet abhängig von `Boilertemperatur_glätten` den gleitenden Durchschnitt. |
|
||||
| **Zeitplan & Thermodynamik**| `calculateRequiredHeat()` und `canBoilerReachTemperature()` berechnen über Masse, Temperaturdifferenz und spezifische Wärmekapazität, ob die Restzeit zur Zielerreichung ausreicht. |
|
||||
| **Betriebslogik & Limits**| `GetCurrentData($Peak)` wertet Temperaturen, Legionellen-Zähler und Peak-Shaving-Status aus und passt die angebotenen `PowerSteps` an. |
|
||||
| **Leistungszuteilung** | `SetAktuelle_Leistung($power)` ermittelt über `GetKontaktIDZuLeistung()` die passende Aktor-ID und schaltet exakt den geforderten Heizstab ein (und alle anderen aus). |
|
||||
| **Legionellenschutz** | Erhöht `LegioCounter` zyklisch. Bei Überschreiten definierter Grenzen (z.B. > 69120 Zyklen) wird `MaxTemp` = `LegioTemp` gesetzt. Priorisierter Nachtbetrieb via `ist_nachts()`. |
|
||||
| **Taktschutz (Idle)** | `CheckIdle()` und `ProcessIdleCounter()` setzen bei Leistungsänderungen den Timer, um erneute Schaltvorgänge temporär zu blockieren. |
|
||||
|
||||
---
|
||||
|
||||
## 8. Zukünftige Erweiterungen
|
||||
|
||||
- **Temperaturschichtung:** Unterstützung für zwei Fühler (Boiler Oben / Boiler Unten) zur präziseren Erkennung der durchgeladenen Energie.
|
||||
@@ -0,0 +1,121 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Konfiguration der nötigen Schaltkontakte und Nennleistungen"
|
||||
},
|
||||
{
|
||||
"type":"Select",
|
||||
"name":"Boilertemperatur_glätten",
|
||||
"caption":"Boilertemperatur glätten",
|
||||
"options":[
|
||||
{
|
||||
"caption":"Ja",
|
||||
"value":true
|
||||
},
|
||||
{
|
||||
"caption":"Nein",
|
||||
"value":false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "ZeitKonstante",
|
||||
"caption": "Zeit Konstante",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Interval",
|
||||
"caption": "Intervall Neuberechnung der Werte Erst für spätere Versionen, aktuell auf 5 lassen!",
|
||||
"suffix": "Sekunden"
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "IdleCounterMax",
|
||||
"caption": "Zyklen zwischen zwei Leistungsänderungen (Multipliziert sich mit Interval)",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type":"List",
|
||||
"name":"LeistungsStufen",
|
||||
"caption":"Anzahl Stufen mit den dazugehörigen Leistungen",
|
||||
"add":true,
|
||||
"delete":true,
|
||||
"columns":[
|
||||
{
|
||||
"caption":"Stufe(n)",
|
||||
"name":"Stufe",
|
||||
"width":"200px",
|
||||
"add":"Stufe",
|
||||
"edit":{
|
||||
"type":"NumberSpinner"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption":"Leistung in W",
|
||||
"name":"Leistung",
|
||||
"width":"300px",
|
||||
"add":0,
|
||||
"edit":{
|
||||
"type":"NumberSpinner"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption":"Schaltkontakt",
|
||||
"name":"Schaltkontakt_Stufe",
|
||||
"width":"400px",
|
||||
"add":0,
|
||||
"edit":{
|
||||
"type":"SelectVariable"
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Boilervolumen",
|
||||
"caption": "Boilervolumen",
|
||||
"suffix": "Liter"
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Boilerfuehler_PT1",
|
||||
"caption": "Variable für Boilerfühler PT1",
|
||||
"test": true
|
||||
},
|
||||
{
|
||||
"type": "List",
|
||||
"name": "Zeitplan",
|
||||
"caption": "Zeitplan für Solltemperaturen",
|
||||
"columns": [
|
||||
{
|
||||
"caption": "Uhrzeit",
|
||||
"name": "Uhrzeit",
|
||||
"width": "150px",
|
||||
"add": "00:00",
|
||||
"edit": {
|
||||
"type": "ValidationTextBox"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption": "Solltemperatur",
|
||||
"name": "Solltemperatur",
|
||||
"width": "150px",
|
||||
"add": 0,
|
||||
"edit": {
|
||||
"type": "NumberSpinner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"add": true,
|
||||
"delete": true,
|
||||
"sort": {
|
||||
"column": "Uhrzeit",
|
||||
"direction": "ascending"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{72B9606B-D5E6-6033-F2E4-0B2C5533F726}",
|
||||
"name": "Warmwasser",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
<?php
|
||||
class Warmwasser extends IPSModule
|
||||
{
|
||||
private array $leistungArray = [];
|
||||
public function Create()
|
||||
{
|
||||
parent::Create();
|
||||
// Boiler spezifische Properties
|
||||
$this->RegisterPropertyString("LeistungsStufen", json_encode([])); // Bezeichnung der Liste
|
||||
$this->RegisterPropertyInteger("ZeitKonstante", 120);
|
||||
$this->RegisterPropertyInteger("Boilerfuehler_PT1", 0);
|
||||
$this->RegisterPropertyBoolean("Boilertemperatur_glätten", false);
|
||||
$this->RegisterPropertyInteger("Boilervolumen", 300);
|
||||
$this->RegisterPropertyString("Zeitplan", "");
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
// Boiler spezifische Variablen
|
||||
$this->RegisterVariableInteger("Mindesttemperatur", "Mindesttemperatur", "", 45);
|
||||
$this->RegisterVariableInteger("Maximaltemperatur", "Maximaltemperatur", "", 60);
|
||||
$this->RegisterVariableInteger("Legionellentemperatur", "Legionellentemperatur", "", 65);
|
||||
$this->RegisterVariableInteger("LegioCounter", "LegioCounter", "", 0);
|
||||
$this->RegisterVariableInteger("Boilertemperatur", "Boilertemperatur", "", 0);
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
$this->RegisterVariableInteger("Power", "Power", '', 0);
|
||||
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving", "", true);
|
||||
$this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 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_Boiler", $this->ReadPropertyInteger("Interval") * 1000, "IPS_RequestAction(" . $this->InstanceID . ', "Do_UserCalc", "");');
|
||||
}
|
||||
public function ApplyChanges()
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
$this->SetTimerInterval("Timer_Do_UserCalc_Boiler", $this->ReadPropertyInteger("Interval") * 1000);
|
||||
}
|
||||
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:
|
||||
break;
|
||||
}
|
||||
}
|
||||
private function LadeUndSortiereLeistungen()
|
||||
{
|
||||
// Array initialisieren, immer mit 0
|
||||
$this->leistungArray = [0];
|
||||
// JSON aus der Property auslesen
|
||||
$json = $this->ReadPropertyString("LeistungsStufen");
|
||||
$leistungsStufen = json_decode($json, true);
|
||||
if (is_array($leistungsStufen))
|
||||
{
|
||||
foreach ($leistungsStufen as $stufe)
|
||||
{
|
||||
$this->leistungArray[] = $stufe['Leistung'] ? ? 0;
|
||||
}
|
||||
}
|
||||
// Array sortieren
|
||||
$len = count($this->leistungArray);
|
||||
for ($i = 0;$i < $len - 1;$i++)
|
||||
{
|
||||
for ($j = 0;$j < $len - $i - 1;$j++)
|
||||
{
|
||||
if ($this->leistungArray[$j] > $this->leistungArray[$j + 1])
|
||||
{
|
||||
$temp = $this->leistungArray[$j];
|
||||
$this->leistungArray[$j] = $this->leistungArray[$j + 1];
|
||||
$this->leistungArray[$j + 1] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Spezialfunktion für Landwirtschaft, Boiler kann auf Uhrzeiten mit einer Solltemperatur beheizt werden
|
||||
public function getNextTimeAndTemperature($zeitplan)
|
||||
{
|
||||
$arr = json_decode($zeitplan, true);
|
||||
if (empty($arr))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
$currentTime = new DateTime();
|
||||
$nextEntry = null;
|
||||
$minDiff = PHP_INT_MAX;
|
||||
foreach ($arr as $entry)
|
||||
{
|
||||
$entryTime = DateTime::createFromFormat('H:i', $entry['Uhrzeit']);
|
||||
if ($entryTime < $currentTime)
|
||||
{
|
||||
$entryTime->modify('+1 day');
|
||||
}
|
||||
$diff = $currentTime->diff($entryTime)->format('%r%a') * 24 * 60 + $currentTime->diff($entryTime)->format('%r%h') * 60 + $currentTime->diff($entryTime)->format('%r%i');
|
||||
if ($diff < $minDiff)
|
||||
{
|
||||
$minDiff = $diff;
|
||||
$nextEntry = $entry;
|
||||
}
|
||||
}
|
||||
return $nextEntry;
|
||||
}
|
||||
// zeit berechnen bis zum nächsten "warmsein"
|
||||
public function calculateRemainingTime($nextTime)
|
||||
{
|
||||
$currentTime = new DateTime();
|
||||
$nextDateTime = DateTime::createFromFormat('H:i', $nextTime);
|
||||
if ($nextDateTime < $currentTime)
|
||||
{
|
||||
$nextDateTime->modify('+1 day');
|
||||
}
|
||||
$interval = $currentTime->diff($nextDateTime);
|
||||
return $interval->h + ($interval->i / 60);
|
||||
}
|
||||
// Wärmemenge berechnen zum nächsten warm sein
|
||||
public function calculateRequiredHeat($boilervolumen, $tempDiff)
|
||||
{
|
||||
// Annahme: spezifische Wärmekapazität von Wasser = 4.186 J/g°C
|
||||
// 1 Liter Wasser = 1000 Gramm
|
||||
$specificHeatCapacity = 4.186; // J/g°C
|
||||
$waterMass = $boilervolumen * 1000; // Gramm
|
||||
return $specificHeatCapacity * $waterMass * $tempDiff; // Joules
|
||||
|
||||
}
|
||||
// Reicht zeit noch aus um wärmemenge zu errecihen , sonst dann später einschalten
|
||||
public function canBoilerReachTemperature($boilervolumen, $boilerTemper, $nextTemp, $remainingTime, $vollleistung)
|
||||
{
|
||||
$tempDiff = $nextTemp - $boilerTemper;
|
||||
$requiredHeat = $this->calculateRequiredHeat($boilervolumen, $tempDiff);
|
||||
$availableHeat = $vollleistung * $remainingTime * 3600; // Leistung in Watt * Zeit in Sekunden
|
||||
return $availableHeat >= $requiredHeat;
|
||||
}
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetAktuelle_Leistung(int $power)
|
||||
{
|
||||
// Lade sicherheitshalber das aktuelle LeistungArray
|
||||
$this->LadeUndSortiereLeistungen();
|
||||
// Schleife über alle Leistungsstufen
|
||||
foreach ($this->leistungArray as $leistung)
|
||||
{
|
||||
$kontaktID = $this->GetKontaktIDZuLeistung($leistung);
|
||||
// Prüfen, ob Variable existiert und gültige ID
|
||||
if ($kontaktID > 0 && IPS_VariableExists($kontaktID))
|
||||
{
|
||||
// Setze TRUE für die aktuelle Leistungsstufe, FALSE für alle anderen
|
||||
SetValue($kontaktID, ($leistung === $power));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($kontaktID > 0)
|
||||
{
|
||||
IPS_LogMessage("ERROR", "KontaktID $kontaktID existiert nicht oder ist ungültig!");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Prüfe auf Änderung der Power 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();
|
||||
}
|
||||
// Variabeln id zu leistung schalten
|
||||
private function GetKontaktIDZuLeistung(int $leistung) : int
|
||||
{
|
||||
$json = $this->ReadPropertyString("LeistungsStufen");
|
||||
$leistungsStufen = json_decode($json, true);
|
||||
if (is_array($leistungsStufen))
|
||||
{
|
||||
foreach ($leistungsStufen as $stufe)
|
||||
{
|
||||
if (($stufe['Leistung'] ? ? 0) == $leistung)
|
||||
{
|
||||
return $stufe['Schaltkontakt_Stufe'] ? ? 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// Methode zum Abrufen der aktuellen Daten
|
||||
public function GetCurrentData(bool $Peak)
|
||||
{
|
||||
$LegioCounter = $this->GetValue("LegioCounter");
|
||||
$this->LadeUndSortiereLeistungen();
|
||||
$boilertemperatur_glätten = $this->ReadPropertyBoolean("Boilertemperatur_glätten");
|
||||
if ($boilertemperatur_glätten)
|
||||
{
|
||||
// Wenn Glättung aktiviert ist, führe das Glätten durch
|
||||
$boilerFuehlerPT1ID = $this->ReadPropertyInteger("Boilerfuehler_PT1");
|
||||
if (IPS_VariableExists($boilerFuehlerPT1ID))
|
||||
{
|
||||
$boilerPT1 = GetValue($boilerFuehlerPT1ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$boilerPT1 = 0.0; // Standardwert
|
||||
|
||||
}
|
||||
$boilerTempID = $this->GetIDForIdent("Boilertemperatur");
|
||||
if (IPS_VariableExists($boilerTempID))
|
||||
{
|
||||
$boilerTemp = $this->GetValue("Boilertemperatur");
|
||||
}
|
||||
else
|
||||
{
|
||||
$boilerTemp = 0.0; // Standardwert
|
||||
|
||||
}
|
||||
// PT
|
||||
$time_constant = $this->ReadPropertyInteger("ZeitKonstante");
|
||||
$delta_t = 5; // Zeitdifferenz zwischen den Messungen (30 Sekunden)
|
||||
$alpha = $delta_t / ($time_constant + $delta_t);
|
||||
$newBoilerTemp = $boilerTemp + $alpha * ($boilerPT1 - $boilerTemp);
|
||||
$this->SetValue("Boilertemperatur", $newBoilerTemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wenn Glättung nicht aktiviert ist, setze die Boilertemperatur direkt auf den Wert des Boilerfühlers
|
||||
$boilerFuehlerPT1ID = $this->ReadPropertyInteger("Boilerfuehler_PT1");
|
||||
if (IPS_VariableExists($boilerFuehlerPT1ID))
|
||||
{
|
||||
$boilerPT1 = GetValue($boilerFuehlerPT1ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$boilerPT1 = 0.0; // Standardwert
|
||||
|
||||
}
|
||||
// Setze Boilertemperatur direkt auf den Wert des Boilerfühlers
|
||||
$this->SetValue("Boilertemperatur", $boilerPT1);
|
||||
}
|
||||
$boilerTemp = $this->GetValue("Boilertemperatur");
|
||||
$minTemp = $this->GetValue("Mindesttemperatur");
|
||||
$maxTemp = $this->GetValue("Maximaltemperatur");
|
||||
$LegioTemp = $this->GetValue("Legionellentemperatur");
|
||||
$nextEntry = $this->getNextTimeAndTemperature($this->ReadPropertyString("Zeitplan"));
|
||||
if ($nextEntry !== null)
|
||||
{
|
||||
$remainingTime = $this->calculateRemainingTime($nextEntry['Uhrzeit']);
|
||||
$nextTemp = $nextEntry['Solltemperatur'];
|
||||
if (!$this->canBoilerReachTemperature($this->ReadPropertyInteger("Boilervolumen") , $boilerTemp, $nextTemp, $remainingTime, $vollLeistung))
|
||||
{
|
||||
$minTemp = $nextTemp;
|
||||
}
|
||||
}
|
||||
// Falluntercheidung auf basis obn wieder legionellen nötig sind
|
||||
if ($boilerTemp > $LegioTemp)
|
||||
{
|
||||
$LegioCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$LegioCounter = $LegioCounter + 1;
|
||||
}
|
||||
if ($LegioCounter > 69120)
|
||||
{
|
||||
$maxTemp = $LegioTemp;
|
||||
}
|
||||
if ($LegioCounter > 120960 && $this->ist_nachts())
|
||||
{
|
||||
$minTemp = $LegioTemp;
|
||||
}
|
||||
if ($LegioCounter > 138240)
|
||||
{ // Timeout für Legio wenn temperatur nicht erreicht werden kann, setze legionellenfunktion zurück
|
||||
$LegioCounter = 0;
|
||||
}
|
||||
$this->SetValue("LegioCounter", $LegioCounter);
|
||||
// Fallunterscheidung ob peakbetrieb ist
|
||||
if ($Peak)
|
||||
{
|
||||
if ($boilerTemp < $minTemp)
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode($this->leistungArray));
|
||||
}
|
||||
elseif ($boilerTemp < $minTemp + 5 && $this->IstEineStufeAktiv())
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode($this->leistungArray));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([0]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($boilerTemp < $minTemp)
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([max($this->leistungArray) ]));
|
||||
}
|
||||
elseif ($boilerTemp < $minTemp + 5 && $this->IstEineStufeAktiv())
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([max($this->leistungArray) ]));
|
||||
}
|
||||
elseif ($boilerTemp < $maxTemp - 5)
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode($this->leistungArray));
|
||||
}
|
||||
elseif ($boilerTemp < $maxTemp && $this->IstEineStufeAktiv())
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode($this->leistungArray));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->SetValue("PowerSteps", json_encode([0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
private function IstEineStufeAktiv() : bool
|
||||
{
|
||||
$json = $this->ReadPropertyString("LeistungsStufen");
|
||||
$leistungsStufen = json_decode($json, true);
|
||||
if (is_array($leistungsStufen))
|
||||
{
|
||||
foreach ($leistungsStufen as $stufe)
|
||||
{
|
||||
$kontaktID = $stufe['Schaltkontakt_Stufe'] ? ? 0;
|
||||
if ($kontaktID > 0 && IPS_VariableExists($kontaktID))
|
||||
{
|
||||
if (GetValue($kontaktID) === true)
|
||||
{
|
||||
return true; // mindestens eine Stufe ist aktiv
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // keine aktiv
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
//Hilfsfunktion für nachtbetrieb, wenn nachttarif noch aktiv ist
|
||||
private function ist_nachts()
|
||||
{
|
||||
date_default_timezone_set("Europe/Berlin"); // Setze hier deine Zeitzone
|
||||
$aktuelle_zeit = strtotime(date("H:i")); // Aktuelle Zeit in Stunden und Minuten umwandeln
|
||||
$start_nacht = strtotime("22:00"); // Startzeit der Nacht (22 Uhr)
|
||||
$ende_nacht = strtotime("07:00"); // Endzeit der Nacht (7 Uhr)
|
||||
if ($aktuelle_zeit >= $start_nacht || $aktuelle_zeit < $ende_nacht)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user