Fallback better settings
This commit is contained in:
		@@ -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"]);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user