1
0

some debbuging :-(

This commit is contained in:
2022-06-10 12:44:09 +02:00
parent cde4d728cf
commit b2f79dd49c
8 changed files with 80 additions and 64 deletions

View File

@ -35,10 +35,11 @@ class db extends mysqli
return $this->real_escape_string($string);
}
function logProperty($device, $property, $value, $oldValue = 0)
function logProperty(&$device, $property, $value)
{
global $mohaDB, $properties2log, $testMode;
$precision = 0;
$oldValue = $device->properties[$property]["lastValueLogged"];
//echo "############## logProperty ################\nproperty => " . $propertyTree .EOL;
//echo "logging in database";
//var_dump($device);
@ -80,13 +81,14 @@ class db extends mysqli
{
logger(ERROR, _("mysql query errror: ") . $this->error, __FILE__ . ":" . __LINE__);
}
$device->properties[$property]["lastValueLogged"] = $value;
logger(INFO, sprintf(_("New value (%s) of property: '%s' of device: %s stored in database"), bool2string($value), $property, $device->friendlyName), __FILE__ . ":" . __LINE__);
}
logger(INFO, sprintf(_("New value (%s) of property: '%s' of device: %s stored in database"), bool2string($value), $property, $device->friendlyName), __FILE__ . ":" . __LINE__);
}
function moyenne($deviceObject, $property, $time)
{
$query = "SELECT AVG(value) as value FROM logs WHERE device='" . $deviceObject->ieeeAddress . "' AND property='" . $property . "' AND TIMEDIFF(NOW(), date) < '00:" . $time . "'";
$query = "SELECT AVG(value) as value FROM logs WHERE device='" . $deviceObject->ieeeAddress . "' AND property='" . $property . "' AND TIMEDIFF(NOW(), date) < '00:" . str_pad($time, 2, "0", STR_PAD_LEFT ) . "'";
logger(DEBUG, _("query is: ") . $query, __FILE__ . ":" . __LINE__);
if(!$this->result = $this->query($query))
{
@ -99,9 +101,6 @@ class db extends mysqli
logger(DEBUG, _("result is: ") . print_r($value, true), __FILE__ . ":" . __LINE__);
return $value[0];
}
}
}