- lots of debugging
- beginning to add graphical stats - beginning to add device by type - added a dashboard "etage" - begining to add notification to multiple recipients in freemobile hook
This commit is contained in:
		
							
								
								
									
										13
									
								
								class/db.php
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								class/db.php
									
									
									
									
									
								
							| @@ -47,7 +47,7 @@ class db extends mysqli | ||||
| 			$ieeeAddress = $device->ieeeAddress; | ||||
| 			//print_r($ieeeAddress); | ||||
| 			$query = "INSERT INTO logs (device, property, value) VALUES('" . $this->protect($ieeeAddress) . "', '" . $this->protect($property) . "', '" . $this->protect(bool2string($value)) . "')"; | ||||
| 			echo $query; | ||||
| 			echo $query . EOL; | ||||
| 			if (is_numeric($value) and !empty($properties2log[$property])) | ||||
| 			{ | ||||
| 				// calculate a min/max value for storing data | ||||
| @@ -56,6 +56,10 @@ class db extends mysqli | ||||
| 				{ | ||||
| 					$minMax = $minMax($value); | ||||
| 				} | ||||
| 				var_dump($value) . EOL; | ||||
| 				var_dump($minMax) . EOL; | ||||
| 				var_dump($oldValue) . EOL; | ||||
| 				if ( !is_numeric($oldValue))	$oldValue = 0; | ||||
| 				//echo "minMax = " .$minMax . EOL; | ||||
| 				//echo "oldValue = " . $oldValue . EOL; | ||||
| 				//echo "Value = " . $value . EOL; | ||||
| @@ -81,12 +85,15 @@ class db extends mysqli | ||||
|  | ||||
| 	function moyenne($deviceObject, $property, $time) | ||||
| 	{ | ||||
| 		$query = "SELECT AVG(value) FROM logs WHERE device='" . $deviceObject->ieeeAddress . "' AND property='" . $property . "' AND TIMEDIFF(NOW(), 'date') < " . $time; | ||||
| 		$query = "SELECT AVG(value) as value FROM logs WHERE device='" . $deviceObject->ieeeAddress . "' AND property='" . $property . "' AND TIMEDIFF(NOW(), date) < '00:" . $time . "'"; | ||||
| 		if(!$this->result = $this->query($query)) | ||||
| 		{ | ||||
| 			logger(ERROR, _("mysql query errror: ") . $this->error, __FILE__ . ":" . __LINE__); | ||||
| 		} | ||||
| 		var_dump($this->result); | ||||
|  | ||||
| 		$value = $this->result->fetch_array(MYSQLI_NUM); | ||||
| 		//var_dump($value); | ||||
| 		return $value[0]; | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user