Version 2.0.0 Beta
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"type":"Select",
|
||||
"name":"Boilertemperatur_glätten",
|
||||
"caption":"Boilertemperatur glätten Ja oder Nein",
|
||||
"caption":"Boilertemperatur glätten",
|
||||
"options":[
|
||||
{
|
||||
"caption":"Ja",
|
||||
@@ -24,24 +24,36 @@
|
||||
"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 Leisutungsänderungen",
|
||||
"caption": "Zyklen zwischen zwei Leistungsänderungen (Multipliziert sich mit Interval)",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "BoilerLeistungTeillast",
|
||||
"caption": "Leistug Teillast",
|
||||
"suffix": ""
|
||||
"suffix": "Watt"
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "BoilerLeistungVolllast",
|
||||
"caption": "Leistug Vollast",
|
||||
"suffix": ""
|
||||
"suffix": "Watt"
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Boilervolumen",
|
||||
"caption": "Boilervolumen",
|
||||
"suffix": "Liter"
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
@@ -60,7 +72,37 @@
|
||||
"name": "Kontakt_Volllast",
|
||||
"caption": "Schaltkontakt Volllast",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
$this->RegisterPropertyInteger("Kontakt_Teillast", 0);
|
||||
$this->RegisterPropertyInteger("Kontakt_Volllast", 0);
|
||||
$this->RegisterPropertyBoolean("Boilertemperatur_glätten", false);
|
||||
$this->RegisterPropertyInteger("Boilervolumen", 300);
|
||||
$this->RegisterPropertyString("Zeitplan", "");
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
|
||||
|
||||
// Boiler spezifische Variablen
|
||||
|
||||
@@ -21,7 +25,6 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
$this->RegisterVariableInteger("Maximaltemperatur","Maximaltemperatur","",60);
|
||||
$this->RegisterVariableInteger("Legionellentemperatur","Legionellentemperatur","",65);
|
||||
$this->RegisterVariableInteger("LegioCounter", "LegioCounter", "", 0);
|
||||
//$this->RegisterVariableInteger("Boilertemperatur", "Boilertemperatur", "", 0);
|
||||
$this->RegisterVariableInteger("Boilertemperatur", "Boilertemperatur", "", 0);
|
||||
|
||||
|
||||
@@ -32,8 +35,9 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
$this->RegisterVariableInteger("Power", "Power", "", 0);
|
||||
$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);
|
||||
@@ -43,13 +47,14 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
// Initialisiere Idle
|
||||
$this->SetValue("Idle", true);
|
||||
|
||||
$this->RegisterTimer("Timer_Do_UserCalc",5000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
|
||||
$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);
|
||||
|
||||
|
||||
|
||||
@@ -78,6 +83,57 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -107,7 +163,7 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
|
||||
// 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();
|
||||
}
|
||||
@@ -139,7 +195,7 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
|
||||
// PT
|
||||
$time_constant= $this->ReadPropertyInteger("ZeitKonstante");
|
||||
$delta_t = 30; // Zeitdifferenz zwischen den Messungen (30 Sekunden)
|
||||
$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);
|
||||
@@ -158,8 +214,6 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$boilerTemp = $this->GetValue("Boilertemperatur");
|
||||
$minTemp = $this->GetValue("Mindesttemperatur");
|
||||
$maxTemp = $this->GetValue("Maximaltemperatur");
|
||||
@@ -167,6 +221,19 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
|
||||
$teilLeistung = $this->ReadPropertyInteger("BoilerLeistungTeillast");
|
||||
$vollLeistung = $this->ReadPropertyInteger("BoilerLeistungVolllast");
|
||||
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$AktuelleVollast = GetValue(
|
||||
$this->ReadPropertyInteger("Kontakt_Volllast")
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user