debugage
This commit is contained in:
15
class/db.php
15
class/db.php
@ -35,27 +35,26 @@ class db extends mysqli
|
||||
return $this->real_escape_string($string);
|
||||
}
|
||||
|
||||
function logProperty($device, $propertyTree, $value, $oldValue = 0)
|
||||
function logProperty($device, $property, $value, $oldValue = 0)
|
||||
{
|
||||
global $mohaDB, $properties2log, $testMode;
|
||||
$precision = 0;
|
||||
//echo "############## logProperty ################\nproperty => " . $propertyTree .EOL;
|
||||
if (array_key_exists($propertyTree, $properties2log))
|
||||
if (array_key_exists($property, $properties2log))
|
||||
{
|
||||
//echo "logging in database";
|
||||
$ieeeAddress = $device->ieeeAddress;
|
||||
//print_r($ieeeAddress);
|
||||
$query = "INSERT INTO logs (device, property, value) VALUES('" . $this->protect($ieeeAddress) . "', '" . $this->protect($propertyTree) . "', '" . $this->protect($value) . "')";
|
||||
if (is_numeric($value) and !empty($properties2log[$propertyTree]))
|
||||
$query = "INSERT INTO logs (device, property, value) VALUES('" . $this->protect($ieeeAddress) . "', '" . $this->protect($property) . "', '" . $this->protect($value) . "')";
|
||||
echo $query;
|
||||
if (is_numeric($value) and !empty($properties2log[$property]))
|
||||
{
|
||||
// calculate a min/max value for storing data
|
||||
|
||||
$minMax = $properties2log[$propertyTree];
|
||||
$minMax = $properties2log[$property];
|
||||
if (is_callable($minMax))
|
||||
{
|
||||
$minMax = $minMax($value);
|
||||
}
|
||||
|
||||
//echo "minMax = " .$minMax . EOL;
|
||||
//echo "oldValue = " . $oldValue . EOL;
|
||||
//echo "Value = " . $value . EOL;
|
||||
@ -75,7 +74,7 @@ class db extends mysqli
|
||||
logger(ERROR, _("mysql query errror: ") . $this->error, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
}
|
||||
logger(INFO, sprintf(_("New value (%s) of property: '%s' of device: %s stored in database"), bool2string($value), $propertyTree, $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__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class hook
|
||||
if (isset($indexDevices[$ieeeAddress]))
|
||||
{
|
||||
$property = $property2change[0];
|
||||
$indexDevices[$ieeeAddress]->$property["functions"][] = array($this,"callback");
|
||||
$indexDevices[$ieeeAddress]->properties[$property]["functions"][] = array($this,"callback");
|
||||
$property2change[1] = true;
|
||||
logger(DEBUG, sprintf(_("Property '%s' is initialized with callback"), $property2change[0]), __FILE__ . ":" . __LINE__);
|
||||
}else
|
||||
|
Reference in New Issue
Block a user