some fix and new firmware for shelly1
This commit is contained in:
		@@ -2,6 +2,9 @@
 | 
			
		||||
/**
 | 
			
		||||
*
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FallbackManager
 | 
			
		||||
{
 | 
			
		||||
	public $deviceDefinitions = "";
 | 
			
		||||
@@ -13,7 +16,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) {
 | 
			
		||||
@@ -21,13 +24,21 @@ class FallbackManager
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (!isset($this->deviceDefinitions[$subDeviceValue['type']]["fallBackTime"])) {
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$lastRecord = RecordManager::getLastRecord($subDeviceValue['subdevice_id']);
 | 
			
		||||
				$minutes = (time() - $lastRecord['time']) / 60;
 | 
			
		||||
				echo $minutes;
 | 
			
		||||
				if ( $minutes > 2){
 | 
			
		||||
				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"]);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}*/
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,25 @@ class LogRecordType{
 | 
			
		||||
	const INFO = 'info';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class LogKeeper
 | 
			
		||||
{
 | 
			
		||||
	function purge($days){
 | 
			
		||||
		$todayFileName = date("Y-m-d").'.log';
 | 
			
		||||
		$seconds = $days * 86400;
 | 
			
		||||
 | 
			
		||||
		$logFiles = scandir('./app/logs/');
 | 
			
		||||
		foreach ($logFiles as $key => $file) {
 | 
			
		||||
			if (in_array($file,array(".","..", ".gitkeep", $todayFileName)))
 | 
			
		||||
			{
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
			if (filemtime($file) > $seconds) {
 | 
			
		||||
				unlink('./app/logs/'.$file);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class LogManager
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ class RecordManager{
 | 
			
		||||
 | 
			
		||||
	public static function clean ($day) {
 | 
			
		||||
		if (isset($day)) {
 | 
			
		||||
			Db::command ('DELETE FROM records WHERE time < ADDDATE(NOW(), INTERVAL -? DAY);', array($day));
 | 
			
		||||
			Db::command ('DELETE FROM records WHERE `time` < ADDDATE(NOW(), INTERVAL -? DAY);', array($day));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ class Template extends Partial{
 | 
			
		||||
	function render() {
 | 
			
		||||
		extract($this->assignedValues);
 | 
			
		||||
		if (!empty('app/controls/' . $this->path . '.php') && file_exists('app/controls/' . $this->path . '.php')) {
 | 
			
		||||
			require_once('app/controls/' . $this->path . '.php');
 | 
			
		||||
			include('app/controls/' . $this->path . '.php');
 | 
			
		||||
		}
 | 
			
		||||
		require_once('app/templates/' . $this->path . '.phtml');
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,15 +9,15 @@ if (isset($_POST) && !empty($_POST)){
 | 
			
		||||
		$onDays = $_POST['atDays'];
 | 
			
		||||
 | 
			
		||||
		//Debug
 | 
			
		||||
		if (DEBUGMOD == 1) {
 | 
			
		||||
			echo '<pre>';
 | 
			
		||||
			echo $permissionsInJson;
 | 
			
		||||
			echo $deviceId;
 | 
			
		||||
			var_dump(json_decode ($permissionsInJson));
 | 
			
		||||
			echo '</pre>';
 | 
			
		||||
			echo '<a href="' . BASEDIR .'">CONTINUE</a>';
 | 
			
		||||
			die();
 | 
			
		||||
		}
 | 
			
		||||
		// if (DEBUGMOD == 1) {
 | 
			
		||||
		// 	echo '<pre>';
 | 
			
		||||
		// 	echo $permissionsInJson;
 | 
			
		||||
		// 	echo $deviceId;
 | 
			
		||||
		// 	var_dump(json_decode ($permissionsInJson));
 | 
			
		||||
		// 	echo '</pre>';
 | 
			
		||||
		// 	echo '<a href="' . BASEDIR .'">CONTINUE</a>';
 | 
			
		||||
		// 	die();
 | 
			
		||||
		// }
 | 
			
		||||
 | 
			
		||||
		AutomationManager::create($_POST['name'], $onDays, $doCode, $ifCode);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -64,16 +64,16 @@ if ('serviceWorker' in navigator) {
 | 
			
		||||
$('select[name="atSelector"]').change(function(e) {
 | 
			
		||||
    console.log($(this).val());
 | 
			
		||||
    if( $(this).val() == 'time') {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        $('input[name="atTime"]').prop( "disabled", false );
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        $('select[name="atDeviceValueInt"]').prop( "disabled", true );
 | 
			
		||||
        $('input[name="atDeviceValue"]').prop( "disabled", true );
 | 
			
		||||
    } else if( $(this).val() == 'atDeviceValue') {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        $('select[name="atDeviceValue"]').prop( "disabled", false );
 | 
			
		||||
        $('input[name="atDeviceValueInt"]').prop( "disabled", false );
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        $('input[name="atTime"]').prop( "disabled", true );
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
@@ -88,7 +88,7 @@ $("div.square-content").on('touchend', function (e){
 | 
			
		||||
$("div.square-content").on('touchstart', function (eTarget) {
 | 
			
		||||
    navigator.vibrate([500]);
 | 
			
		||||
    var id = '';
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    var windowLoc = $(location).attr('pathname');
 | 
			
		||||
    windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
 | 
			
		||||
    console.log(windowLoc);
 | 
			
		||||
@@ -99,9 +99,9 @@ $("div.square-content").on('touchstart', function (eTarget) {
 | 
			
		||||
    } else if (windowLoc == "/automation") {
 | 
			
		||||
        id = $(this).attr('id').replace('automation-', '');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    var subId = $(this).attr('data-sub-device-id');
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    touch++;
 | 
			
		||||
    if(touch == 2 && touchSubId == subId){
 | 
			
		||||
        console.log("Detail");
 | 
			
		||||
@@ -109,7 +109,7 @@ $("div.square-content").on('touchstart', function (eTarget) {
 | 
			
		||||
            $("#modal-detail-"+subId).removeClass('modal-container-hiden').show();
 | 
			
		||||
            ajaxChart(subId);
 | 
			
		||||
        } else if (windowLoc == "/scene") {
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        } else if (windowLoc == "/automation") {
 | 
			
		||||
        }
 | 
			
		||||
        touch = 0;
 | 
			
		||||
@@ -117,7 +117,7 @@ $("div.square-content").on('touchstart', function (eTarget) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    touchSubId = subId;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    pressTimer = window.setTimeout(function (e) {
 | 
			
		||||
        console.log("Setting");
 | 
			
		||||
        $("#modal-setting-"+id).removeClass('modal-container-hiden').show();
 | 
			
		||||
@@ -202,14 +202,14 @@ var windowLoc = $(location).attr('pathname');
 | 
			
		||||
windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
 | 
			
		||||
console.log();
 | 
			
		||||
if (windowLoc == "/") {
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    var selectRoomId = localStorage.getItem("selectedRoomId");
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if (selectRoomId == null) {
 | 
			
		||||
        selectRoomId = 'all';
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    console.log('Saved Selected Room ID '+ selectRoomId);
 | 
			
		||||
    $('[name="room"]').val(selectRoomId);
 | 
			
		||||
    $('.device-button').each(function(){
 | 
			
		||||
@@ -221,8 +221,8 @@ if (windowLoc == "/") {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Room selector
 | 
			
		||||
@@ -239,51 +239,55 @@ $( '[name="room"]' ).change(function (e) {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
var windowLoc = $(location).attr('pathname');
 | 
			
		||||
windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
 | 
			
		||||
console.log();
 | 
			
		||||
if (windowLoc == "/") {
 | 
			
		||||
var autoUpdate = setInterval(function(){
 | 
			
		||||
if (pending == false) {
 | 
			
		||||
pending = true;
 | 
			
		||||
$.ajax({
 | 
			
		||||
url: 'ajax',
 | 
			
		||||
type: 'POST',
 | 
			
		||||
dataType: 'json',
 | 
			
		||||
data: {
 | 
			
		||||
"action": 'getState'
 | 
			
		||||
},
 | 
			
		||||
success: function(data){
 | 
			
		||||
console.log(data);
 | 
			
		||||
for (const key in data) {
 | 
			
		||||
if (data.hasOwnProperty(key)) {
 | 
			
		||||
const device = data[key];
 | 
			
		||||
$('[data-sub-device-id="'+key+'"]')
 | 
			
		||||
.find('.device-button-value')
 | 
			
		||||
.text(device['value'])
 | 
			
		||||
.attr('title',device['time'])
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
},
 | 
			
		||||
error: function (request, status, error) {
 | 
			
		||||
console.log("ERROR ajaxChart():", request, error);
 | 
			
		||||
},
 | 
			
		||||
complete: function (){
 | 
			
		||||
pending = false;
 | 
			
		||||
}
 | 
			
		||||
});
 | 
			
		||||
}
 | 
			
		||||
},4000);
 | 
			
		||||
    var autoUpdate = setInterval(function(){
 | 
			
		||||
        if (pending == false) {
 | 
			
		||||
            pending = true;
 | 
			
		||||
            $.ajax({
 | 
			
		||||
                url: 'ajax',
 | 
			
		||||
                type: 'POST',
 | 
			
		||||
                dataType: 'json',
 | 
			
		||||
                data: {
 | 
			
		||||
                    "action": 'getState'
 | 
			
		||||
                },
 | 
			
		||||
                success: function(data){
 | 
			
		||||
                    console.log(data);
 | 
			
		||||
                    for (const key in data) {
 | 
			
		||||
                        if (data.hasOwnProperty(key)) {
 | 
			
		||||
                            const device = data[key];
 | 
			
		||||
                            $('[data-sub-device-id="'+key+'"]')
 | 
			
		||||
                            .find('.device-button-value')
 | 
			
		||||
                            .text(device['value'])
 | 
			
		||||
                            .attr('title',device['time'])
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                error: function (request, status, error) {
 | 
			
		||||
                    console.log("ERROR ajaxChart():", request, error);
 | 
			
		||||
                },
 | 
			
		||||
                complete: function (){
 | 
			
		||||
                    pending = false;
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    },4000);
 | 
			
		||||
}*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//Graphs
 | 
			
		||||
$('.graph-period').on('click', function (e) {
 | 
			
		||||
    var subId = $(this).attr('data-sub-device-id');
 | 
			
		||||
    var period = $(this).attr('data-period');
 | 
			
		||||
    var groupBy = $(this).attr('data-group');
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    ajaxChart(subId, period, groupBy);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="col-md-9 main-body">
 | 
			
		||||
            <div class="col-12 col-sm-9 mx-auto mt-4">
 | 
			
		||||
                <label><?php echo $LANGMNG->get('l_logMaxLiveTime') . " " . $LOGTOLIVETIME . " days";?></label>
 | 
			
		||||
                <form method="post" action="">
 | 
			
		||||
                    <div class="field">
 | 
			
		||||
                        <select class="input" name="LogFile">
 | 
			
		||||
 
 | 
			
		||||
@@ -22,11 +22,11 @@
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="label"><?php $LANGMNG->echo('l_permission'); ?></div>
 | 
			
		||||
                    <div class="row">
 | 
			
		||||
                        
 | 
			
		||||
 | 
			
		||||
                        <div class="col-6">
 | 
			
		||||
                            <div class="label"> - <?php $LANGMNG->echo('l_owner'); ?></div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        
 | 
			
		||||
 | 
			
		||||
                        <div class="col-6">
 | 
			
		||||
                            <?php
 | 
			
		||||
                            $permissions = $DEVICE['permission'];
 | 
			
		||||
@@ -40,7 +40,7 @@
 | 
			
		||||
                            <input type="radio" name="permissionOwner" value=1 <?php ECHO ($permissions[0] == 1 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_read'); ?>
 | 
			
		||||
                            <input type="radio" name="permissionOwner" value=2 <?php ECHO ($permissions[0] == 2 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_use'); ?>
 | 
			
		||||
                            <input type="radio" name="permissionOwner" value=3 <?php ECHO ($permissions[0] == 3 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_edit'); ?>
 | 
			
		||||
                            
 | 
			
		||||
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="row">
 | 
			
		||||
@@ -156,10 +156,10 @@
 | 
			
		||||
                            <div class="device-button col-4 col-sm-3 col-xl-2 square-wrap">
 | 
			
		||||
                                <div class="square">
 | 
			
		||||
                                    <div class="square-content">
 | 
			
		||||
                                        
 | 
			
		||||
 | 
			
		||||
                                        <?php echo $DEVICE['name']; ?>
 | 
			
		||||
                                        
 | 
			
		||||
                                        
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                </div>
 | 
			
		||||
                            </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -145,6 +145,77 @@ class Ajax extends Template
 | 
			
		||||
				echo 'no action detected';
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		} else if	(
 | 
			
		||||
			isset($_POST['action']) &&
 | 
			
		||||
			$_POST['action'] != ''
 | 
			
		||||
		) {
 | 
			
		||||
			$updateData = [];
 | 
			
		||||
			$allDevicesData = DeviceManager::getAllDevices();
 | 
			
		||||
			foreach ($allDevicesData as $deviceKey => $deviceValue) {
 | 
			
		||||
				$allSubDevices = SubDeviceManager::getAllSubDevices($deviceValue['device_id']);
 | 
			
		||||
				foreach ($allSubDevices as $key => $subDevicesData) {
 | 
			
		||||
 | 
			
		||||
					$lastRecord = RecordManager::getLastRecord($subDevicesData['subdevice_id']);
 | 
			
		||||
					$parsedValue = $lastRecord['value'] . $subDevicesData['unit'];
 | 
			
		||||
 | 
			
		||||
					//TODO: udělat parser a ten použít jak v houmu tak zde
 | 
			
		||||
					switch ($subDevicesData['type']) {
 | 
			
		||||
						case 'on/off':
 | 
			
		||||
						$replacementTrue = 'On';
 | 
			
		||||
						$replacementFalse = 'Off';
 | 
			
		||||
						$operator = '==';
 | 
			
		||||
						$breakValue = 1;
 | 
			
		||||
						break;
 | 
			
		||||
 | 
			
		||||
						case 'door':
 | 
			
		||||
						$replacementTrue = 'Closed';
 | 
			
		||||
						$replacementFalse = 'Open';
 | 
			
		||||
						$operator = '==';
 | 
			
		||||
						$breakValue = 1;
 | 
			
		||||
						break;
 | 
			
		||||
 | 
			
		||||
						case 'light':
 | 
			
		||||
							$replacementTrue = 'Light';
 | 
			
		||||
							$replacementFalse = 'Dark';
 | 
			
		||||
							$operator = '==';
 | 
			
		||||
							$breakValue = 1;
 | 
			
		||||
							if ($lastRecord['value'] != 1 && $lastRecord['value'] != 0) { //Digital Light Senzor
 | 
			
		||||
								$operator = '<';
 | 
			
		||||
								$breakValue = 810;
 | 
			
		||||
							}
 | 
			
		||||
						break;
 | 
			
		||||
 | 
			
		||||
						case 'water':
 | 
			
		||||
						$replacementTrue = 'Wet';
 | 
			
		||||
						$replacementFalse = 'Dry';
 | 
			
		||||
						$operator = '==';
 | 
			
		||||
						$breakValue = 1;
 | 
			
		||||
						break;
 | 
			
		||||
 | 
			
		||||
						default:
 | 
			
		||||
						$replacementTrue = '';
 | 
			
		||||
						$replacementFalse = '';
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					if ($replacementTrue != '' && $replacementFalse != '') {
 | 
			
		||||
						//parsing last values
 | 
			
		||||
						$parsedValue = $replacementFalse;
 | 
			
		||||
 | 
			
		||||
						if (Utilities::checkOperator($lastRecord['value'], $operator, $breakValue)) {
 | 
			
		||||
							$parsedValue = $replacementTrue;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					$updateData[$subDevicesData['subdevice_id']] = [
 | 
			
		||||
						'time' => $lastRecord['time'],
 | 
			
		||||
						'value' => $parsedValue,
 | 
			
		||||
					];
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			//TODO: PRO JS VRACET DATA
 | 
			
		||||
			echo json_encode($updateData, JSON_PRETTY_PRINT);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,11 +7,6 @@ class Home extends Template
 | 
			
		||||
	{
 | 
			
		||||
		global $userManager;
 | 
			
		||||
		global $langMng;
 | 
			
		||||
		$roomManager = new RoomManager();
 | 
			
		||||
		$deviceManager = new DeviceManager();
 | 
			
		||||
		$subDeviceManager = new SubDeviceManager();
 | 
			
		||||
		$recordManager = new RecordManager();
 | 
			
		||||
		$utilities = new Utilities();
 | 
			
		||||
 | 
			
		||||
		if (!$userManager->isLogin()){
 | 
			
		||||
			header('Location: ' . BASEDIR . 'login');
 | 
			
		||||
@@ -20,7 +15,7 @@ class Home extends Template
 | 
			
		||||
		$template = new Template('home');
 | 
			
		||||
 | 
			
		||||
		//users instantialize
 | 
			
		||||
		$users = $userManager->getUsers();
 | 
			
		||||
		$users = UserManager::getUsers();
 | 
			
		||||
		$template->prepare('users', $users);
 | 
			
		||||
 | 
			
		||||
		//Users at home Info
 | 
			
		||||
@@ -39,16 +34,16 @@ class Home extends Template
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		$roomsItems = [];
 | 
			
		||||
		$roomsData = $roomManager->getAllRooms();
 | 
			
		||||
		$roomsData = RoomManager::getAllRooms();
 | 
			
		||||
		foreach ($roomsData as $roomKey => $roomsData) {
 | 
			
		||||
			$devices = [];
 | 
			
		||||
			$devicesData = $deviceManager->getAllDevicesInRoom($roomsData['room_id']);
 | 
			
		||||
			$devicesData = DeviceManager::getAllDevicesInRoom($roomsData['room_id']);
 | 
			
		||||
			foreach ($devicesData as $deviceKey => $deviceData) {
 | 
			
		||||
				$subDevices = [];
 | 
			
		||||
				$subDevicesData = $subDeviceManager->getAllSubDevices($deviceData['device_id']);
 | 
			
		||||
				$subDevicesData = SubDeviceManager::getAllSubDevices($deviceData['device_id']);
 | 
			
		||||
				foreach ($subDevicesData as $subDeviceKey => $subDeviceData) {
 | 
			
		||||
 | 
			
		||||
					$events = $recordManager->getLastRecord($subDeviceData['subdevice_id'], 5);
 | 
			
		||||
					$events = RecordManager::getLastRecord($subDeviceData['subdevice_id'], 5);
 | 
			
		||||
					$eventsRaw = $events;
 | 
			
		||||
 | 
			
		||||
					$connectionError = true;
 | 
			
		||||
@@ -105,7 +100,7 @@ class Home extends Template
 | 
			
		||||
							//parsing last values
 | 
			
		||||
							$parsedValue = $replacementFalse;
 | 
			
		||||
 | 
			
		||||
							if ($utilities->checkOperator($lastValue, $operator, $breakValue)) {
 | 
			
		||||
							if (Utilities::checkOperator($lastValue, $operator, $breakValue)) {
 | 
			
		||||
								$parsedValue = $replacementTrue;
 | 
			
		||||
							}
 | 
			
		||||
 | 
			
		||||
@@ -113,14 +108,14 @@ class Home extends Template
 | 
			
		||||
							//parsing last events values
 | 
			
		||||
							foreach ($events as $key => $value) {
 | 
			
		||||
								$events[$key]['value'] = $replacementFalse;
 | 
			
		||||
								if ($utilities->checkOperator($value['value'], $operator, $breakValue)) {
 | 
			
		||||
								if (Utilities::checkOperator($value['value'], $operator, $breakValue)) {
 | 
			
		||||
									$events[$key]['value'] = $replacementTrue;
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						$LastRecordTime = new DateTime($lastRecord['time']);
 | 
			
		||||
						$niceTime = $utilities->ago($LastRecordTime);
 | 
			
		||||
						$niceTime = Utilities::ago($LastRecordTime);
 | 
			
		||||
 | 
			
		||||
						$interval = $LastRecordTime->diff(new DateTime());
 | 
			
		||||
						$hours   = $interval->format('%h');
 | 
			
		||||
@@ -180,7 +175,7 @@ class Home extends Template
 | 
			
		||||
			];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$rooms = $roomManager->getAllRooms();
 | 
			
		||||
		$rooms = RoomManager::getAllRooms();
 | 
			
		||||
		$template->prepare('baseDir', BASEDIR);
 | 
			
		||||
		$template->prepare('debugMod', DEBUGMOD);
 | 
			
		||||
		$template->prepare('title', 'Home');
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,8 @@ class Log extends Template
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$template->prepare('baseDir', BASEDIR);
 | 
			
		||||
		$template->prepare('debugMod', DEBUGMOD);
 | 
			
		||||
		$template->prepare('logToLiveTime', LOGTIMOUT);
 | 
			
		||||
		$template->prepare('title', 'Logy');
 | 
			
		||||
		$template->prepare('logsFiles', $result);
 | 
			
		||||
		$template->prepare('langMng', $langMng);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user