no message

This commit is contained in:
2025-02-05 16:07:02 +01:00
parent 6116815b1a
commit 0f8c3206bd
2 changed files with 17 additions and 8 deletions

View File

@@ -82,18 +82,27 @@ class Boiler_2_Stufig_Landwirtschaft extends IPSModule
}
public function getNextTimeAndTemperature($zeitplan) {
$arr = json_decode($zeitplan);
if (empty($arr)) {
$arr = json_decode($zeitplan, true);
if (empty($arr)) {
return null;
}
$currentTime = date('H:i');
$currentTime = new DateTime();
$nextEntry = null;
$minDiff = PHP_INT_MAX;
foreach ($arr as $entry) {
if ($entry['Uhrzeit'] > $currentTime) {
return $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;
}
}
// Falls keine spätere Uhrzeit gefunden wird, nimm den ersten Eintrag am nächsten Tag
return $zeitplan[0];
return $nextEntry;
}
public function calculateRemainingTime($nextTime) {

View File

@@ -6,7 +6,7 @@
"compatibility": {
"version": "7.1"
},
"version": "1.034",
"version": "1.035",
"build": 0,
"date": 0
}