das ganze zum normalen boiler rübergenommen

This commit is contained in:
2025-02-05 16:22:16 +01:00
parent 0f8c3206bd
commit d0c30a13d4
3 changed files with 105 additions and 6 deletions
+39 -3
View File
@@ -7,7 +7,7 @@
{
"type":"Select",
"name":"Boilertemperatur_glätten",
"caption":"Boilertemperatur glätten Ja oder Nein",
"caption":"Boilertemperatur glätten",
"options":[
{
"caption":"Ja",
@@ -43,6 +43,12 @@
"caption": "Leistug Vollast",
"suffix": ""
},
{
"type": "NumberSpinner",
"name": "Boilervolumen",
"caption": "Boilervolumen",
"suffix": "Liter"
},
{
"type": "SelectVariable",
"name": "Boilerfuehler_PT1",
@@ -60,7 +66,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"
}
}
]
}
}
+65 -2
View File
@@ -14,6 +14,9 @@ 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", "");
// Boiler spezifische Variablen
@@ -78,6 +81,55 @@ 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)
{
@@ -158,8 +210,6 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule
}
$boilerTemp = $this->GetValue("Boilertemperatur");
$minTemp = $this->GetValue("Mindesttemperatur");
$maxTemp = $this->GetValue("Maximaltemperatur");
@@ -167,6 +217,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")
);
+1 -1
View File
@@ -6,7 +6,7 @@
"compatibility": {
"version": "7.1"
},
"version": "1.035",
"version": "1.036",
"build": 0,
"date": 0
}