diff --git a/app/class/FallbackManager.php b/app/class/FallbackManager.php index a775074..31dc53a 100644 --- a/app/class/FallbackManager.php +++ b/app/class/FallbackManager.php @@ -13,7 +13,7 @@ class FallbackManager function check(){ //TODO: FIX IT - /*$allDevicesData = DeviceManager::getAllDevices(); + $allDevicesData = DeviceManager::getAllDevices(); foreach ($allDevicesData as $deviceKey => $deviceValue) { $allSubDevicesData = SubDeviceManager::getAllSubDevices($deviceValue['device_id']); foreach ($allSubDevicesData as $subDeviceKey => $subDeviceValue) { @@ -22,12 +22,15 @@ class FallbackManager } $lastRecord = RecordManager::getLastRecord($subDeviceValue['subdevice_id']); - $minutes = (time() - $lastRecord['time']) / 60; - echo $minutes; - if ( $minutes > 2){ + if ($lastRecord["value"] == $this->deviceDefinitions[$subDeviceValue['type']]["fallBack"]) { + return; + } + + $minutes = (strtotime($lastRecord['time']) - time()) / 60; + if ( $minutes > 3){ RecordManager::create($deviceValue['device_id'], $subDeviceValue['type'], $this->deviceDefinitions[$subDeviceValue['type']]["fallBack"]); } } - }*/ + } } }