Aditional changes afiliated to log
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -4,3 +4,4 @@ _nemazat/index.html
 | 
				
			|||||||
_nemazat/css/main.css.map
 | 
					_nemazat/css/main.css.map
 | 
				
			||||||
_nemazat/css/main.css
 | 
					_nemazat/css/main.css
 | 
				
			||||||
_nemazat/css/font-awesome.min.css
 | 
					_nemazat/css/font-awesome.min.css
 | 
				
			||||||
 | 
					logs/*.log
 | 
				
			||||||
							
								
								
									
										8
									
								
								api.php
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								api.php
									
									
									
									
									
								
							@@ -41,7 +41,7 @@ if (DEBUGMOD != 1) {
 | 
				
			|||||||
			'errorMSG' => "Using API from your IP insn´t alowed!",
 | 
								'errorMSG' => "Using API from your IP insn´t alowed!",
 | 
				
			||||||
		));
 | 
							));
 | 
				
			||||||
		header("HTTP/1.1 401 Unauthorized");
 | 
							header("HTTP/1.1 401 Unauthorized");
 | 
				
			||||||
		$logManager->write("acces denied from " . $_SERVER['REMOTE_ADDR'], LogRecordType::WARNING);
 | 
							$logManager->write("[API] acces denied from " . $_SERVER['REMOTE_ADDR'], LogRecordType::WARNING);
 | 
				
			||||||
		exit();
 | 
							exit();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -78,7 +78,7 @@ if (!DeviceManager::registeret($token)) {
 | 
				
			|||||||
		'state' => 'unsuccess',
 | 
							'state' => 'unsuccess',
 | 
				
			||||||
		'errorMSG' => "Device not registeret",
 | 
							'errorMSG' => "Device not registeret",
 | 
				
			||||||
	));
 | 
						));
 | 
				
			||||||
	$logManager->write("Registering Device", LogRecordType::INFO);
 | 
						$logManager->write("[API] Registering Device", LogRecordType::INFO);
 | 
				
			||||||
	exit();
 | 
						exit();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -102,7 +102,7 @@ if ($values != null || $values != "") {
 | 
				
			|||||||
			SubDeviceManager::create($deviceId, $key, UNITS[$key]);
 | 
								SubDeviceManager::create($deviceId, $key, UNITS[$key]);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		RecordManager::create($deviceId, $key, round($value['value'],2));
 | 
							RecordManager::create($deviceId, $key, round($value['value'],2));
 | 
				
			||||||
		$logManager->write("Device_ID " . $deviceId . " writed value " . $key . $value['value'], LogRecordType::INFO);
 | 
							$logManager->write("[API] Device_ID " . $deviceId . " writed value " . $key . $value['value'], LogRecordType::INFO);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	$hostname = strtolower($device['name']);
 | 
						$hostname = strtolower($device['name']);
 | 
				
			||||||
@@ -131,7 +131,7 @@ if ($values != null || $values != "") {
 | 
				
			|||||||
		$subDeviceLastReordValue = $subDeviceLastReord['value'];
 | 
							$subDeviceLastReordValue = $subDeviceLastReord['value'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ($subDeviceLastReord['execuded'] == 0){
 | 
							if ($subDeviceLastReord['execuded'] == 0){
 | 
				
			||||||
			$logManager->write("subDevice id ".$subDeviceId . " executed comand with value " .$subDeviceLastReordValue . " record id " . $subDeviceLastReord['record_id'] . " executed " . $subDeviceLastReord['execuded']);
 | 
								$logManager->write("[API] subDevice id ".$subDeviceId . " executed comand with value " .$subDeviceLastReordValue . " record id " . $subDeviceLastReord['record_id'] . " executed " . $subDeviceLastReord['execuded']);
 | 
				
			||||||
			RecordManager::setExecuted($subDeviceLastReord['record_id']);
 | 
								RecordManager::setExecuted($subDeviceLastReord['record_id']);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -116,8 +116,10 @@ class AutomationManager{
 | 
				
			|||||||
						foreach ($sceneDoArray as $deviceId => $deviceState) {
 | 
											foreach ($sceneDoArray as $deviceId => $deviceState) {
 | 
				
			||||||
							RecordManager::create($deviceId, 'on/off', $deviceState);
 | 
												RecordManager::create($deviceId, 'on/off', $deviceState);
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
 | 
											$logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was executed");
 | 
				
			||||||
						Db::edit('automation', array('executed' => 1), 'WHERE automation_id = ?', array($automation['automation_id']));
 | 
											Db::edit('automation', array('executed' => 1), 'WHERE automation_id = ?', array($automation['automation_id']));
 | 
				
			||||||
					} else if ($restart) {
 | 
										} else if ($restart) {
 | 
				
			||||||
 | 
											$logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was restarted");
 | 
				
			||||||
						Db::edit('automation', array('executed' => 0), 'WHERE automation_id = ?', array($automation['automation_id']));
 | 
											Db::edit('automation', array('executed' => 0), 'WHERE automation_id = ?', array($automation['automation_id']));
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user