no message
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"compatibility": {
|
||||
"version": "7.1"
|
||||
},
|
||||
"version": "1.034",
|
||||
"version": "1.035",
|
||||
"build": 0,
|
||||
"date": 0
|
||||
}
|
||||
Reference in New Issue
Block a user