1
0

debug\ncode optimization

This commit is contained in:
2022-01-19 00:22:34 +01:00
parent 11a2253804
commit e4703dafc8
15 changed files with 135 additions and 82 deletions

View File

@ -183,13 +183,16 @@ function iterateDevice($topic, $fn, $parentDevice, &$device, $payloadArray, $pro
}else
{
if (empty($device->$key) or $value != null)
{
//if (empty($device->$key) or $value != null)
//{
if (property_exists($device, $key))
{
if (is_array($device->$key))
{
$oldValue = $device->$key["value"];
if (!empty($device->$key["value"]))
{
$oldValue = $device->$key["value"];
}
}else
{
$oldValue = $device->$key;
@ -202,16 +205,10 @@ function iterateDevice($topic, $fn, $parentDevice, &$device, $payloadArray, $pro
if ($oldValue !== $value)
{
$device->$key["value"] = $value;
$changed[$fn]["key"] = $key;
$changed[$fn]["value"] = $value;
logger(INFO, sprintf(_("Device %s property %s, value changed to %s"), $fn, $propertyTree . $key, $value));
if ($testMode === false)
{
$mohaDB->logProperty($parentDevice, $propertyTree . $key, $value, $oldValue);
}else
{
logger(INFO, _("Test mode on: not storing in DB "));
}
//$changed[$fn]["key"] = $key;
//$changed[$fn]["value"] = $value;
logger(INFO, sprintf(_("Device %s property %s, %s"), $fn, $propertyTree . $key, bool2string($value)));
$mohaDB->logProperty($parentDevice, $propertyTree . $key, $value, $oldValue);
}
if (!empty($device->$key["functions"]))
{
@ -221,7 +218,7 @@ function iterateDevice($topic, $fn, $parentDevice, &$device, $payloadArray, $pro
$function($device, $key, $value);
}
}
}
//}
}
}
}