no message
This commit is contained in:
@@ -82,18 +82,27 @@ class Boiler_2_Stufig_Landwirtschaft extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getNextTimeAndTemperature($zeitplan) {
|
public function getNextTimeAndTemperature($zeitplan) {
|
||||||
$arr = json_decode($zeitplan);
|
$arr = json_decode($zeitplan, true);
|
||||||
if (empty($arr)) {
|
if (empty($arr)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$currentTime = date('H:i');
|
$currentTime = new DateTime();
|
||||||
|
$nextEntry = null;
|
||||||
|
$minDiff = PHP_INT_MAX;
|
||||||
|
|
||||||
foreach ($arr as $entry) {
|
foreach ($arr as $entry) {
|
||||||
if ($entry['Uhrzeit'] > $currentTime) {
|
$entryTime = DateTime::createFromFormat('H:i', $entry['Uhrzeit']);
|
||||||
return $entry;
|
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) {
|
public function calculateRemainingTime($nextTime) {
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "1.034",
|
"version": "1.035",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user