diff --git a/api.php b/api.php index e727e8b..4b682b5 100644 --- a/api.php +++ b/api.php @@ -69,6 +69,8 @@ if (DEBUGMOD != 1) { //automationExecution try { + $fallbackManager = new FallbackManager(RANGES); + $fallbackManager->check(); AutomationManager::executeAll(); } catch (\Exception $e) { $logManager->write("[Automation] Something happen during automation execution", LogRecordType::ERROR); diff --git a/app/class/FallbackManager.php b/app/class/FallbackManager.php new file mode 100644 index 0000000..a775074 --- /dev/null +++ b/app/class/FallbackManager.php @@ -0,0 +1,33 @@ +deviceDefinitions = $deviceDefinition; + } + + function check(){ + //TODO: FIX IT + /*$allDevicesData = DeviceManager::getAllDevices(); + foreach ($allDevicesData as $deviceKey => $deviceValue) { + $allSubDevicesData = SubDeviceManager::getAllSubDevices($deviceValue['device_id']); + foreach ($allSubDevicesData as $subDeviceKey => $subDeviceValue) { + if (!isset($this->deviceDefinitions[$subDeviceValue['type']]["fallBack"])) { + continue; + } + + $lastRecord = RecordManager::getLastRecord($subDeviceValue['subdevice_id']); + $minutes = (time() - $lastRecord['time']) / 60; + echo $minutes; + if ( $minutes > 2){ + RecordManager::create($deviceValue['device_id'], $subDeviceValue['type'], $this->deviceDefinitions[$subDeviceValue['type']]["fallBack"]); + } + } + }*/ + } +}