From 15d95dae1d1766044ec10522238bb848dff548c2 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Sat, 15 Feb 2020 14:02:18 +0100 Subject: [PATCH] Fallback better settings --- app/class/FallbackManager.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/class/FallbackManager.php b/app/class/FallbackManager.php index 31dc53a..cb3fb79 100644 --- a/app/class/FallbackManager.php +++ b/app/class/FallbackManager.php @@ -2,6 +2,9 @@ /** * */ + + + class FallbackManager { public $deviceDefinitions = ""; @@ -21,13 +24,18 @@ class FallbackManager continue; } - $lastRecord = RecordManager::getLastRecord($subDeviceValue['subdevice_id']); - if ($lastRecord["value"] == $this->deviceDefinitions[$subDeviceValue['type']]["fallBack"]) { - return; + if (!isset($this->deviceDefinitions[$subDeviceValue['type']]["fallBackTime"])) { + continue; } - $minutes = (strtotime($lastRecord['time']) - time()) / 60; - if ( $minutes > 3){ + $lastRecord = RecordManager::getLastRecord($subDeviceValue['subdevice_id']); + if ($lastRecord["value"] == $this->deviceDefinitions[$subDeviceValue['type']]["fallBack"]) { + continue; + } + + $minutes = (time() - strtotime($lastRecord['time'])) / 60; + + if ( $minutes > $this->deviceDefinitions[$subDeviceValue['type']]["fallBackTime"]){ RecordManager::create($deviceValue['device_id'], $subDeviceValue['type'], $this->deviceDefinitions[$subDeviceValue['type']]["fallBack"]); } }