1
0

a lot of debug

This commit is contained in:
2022-04-23 02:00:52 +02:00
parent f8fc3f63ec
commit d1f1065e44
21 changed files with 544 additions and 217 deletions

View File

@ -5,7 +5,7 @@ if (!array_key_exists("zigbee2mqtt", $devices)) $devices["zigbee2mqtt"] = array
function zigbee2mqttCallback($topic, $message)
{
global $topics, $devices, $included, $logFh, $indexFriendlyNames;
global $topics, $devices, $included, $logFh, $indexFriendlyNames, $devicesRequest;
if ($topic[1] == "bridge")
{
@ -20,6 +20,7 @@ function zigbee2mqttCallback($topic, $message)
//fwrite($logFh, var_export($topics[$topic[0]]->devices, true));
mkDevicesDB($topic[0], $topics[$topic[0]]->devices);
getDevicesValues($topic[0]);
$devicesRequest = false;
break;
case "groups":
logger(DEBUG,_("Inserting zigbee groups in DB"), __FILE__ . ":" . __LINE__);
@ -77,7 +78,7 @@ function zigbee2mqttCallback($topic, $message)
$alert = 0;
while (!array_key_exists($fn, $indexFriendlyNames))
{
logger(INFO, _("device does not exists in IndexFriendlyNames: ") . print_r($payloadArray,true), __FILE__ . ":" . __LINE__);
logger(ERROR, $fn . _(" device does not exists in IndexFriendlyNames: ") . print_r($payloadArray,true), __FILE__ . ":" . __LINE__);
if ($flag == 0)
{
logger(INFO, "Reindexing all indexes", __FILE__ . ":" . __LINE__);
@ -86,26 +87,32 @@ function zigbee2mqttCallback($topic, $message)
}elseif($flag == 1)
{
logger(INFO, "getting device list from zigbee2mqtt", __FILE__ . ":" . __LINE__);
publish("zigbee2mqtt", array("bridge/devices" => ""), "get");
if ($devicesRequest === false)
{
publish("zigbee2mqtt", array("bridge/devices" => ""), "get");
}
$flag += 1;
}elseif($flag >= 2)
}elseif($flag++ >= 5)
{
$flage = 0;
if ($alert++ > 4)
{
logger(ALERT, _("device does not exists in IndexFriendlyNames: ") . $fn, __FILE__ . ":" . __LINE__);
break;
}
//if ($alert++ > 4)
//{
logger(ERROR, _(" stopping searching for ") . $fn . " payloadArray =>" . print_r($payloadArray, true), __FILE__ . ":" . __LINE__);
break;
//}
}
}
//logger(DEBUG, "PayloadArray = " . print_r($payloadArray,true), __FILE__ . ":" . __LINE__);
if ($alert <= 4)
if ($flag <= 4)
{
changeDevice($topicName, $fn, $indexFriendlyNames[$fn], $payloadArray);
}else
{
logger(ERROR, $fn . _(" not changed"), __FILE__ . ":" . __LINE__);
}
}else
{
logger(DEBUG, _("Zigbee2mqtt doing get or set !?"));
logger(DEBUG, _("Zigbee2mqtt doing get or hooks not included !?"), __FILE__ . ":" . __LINE__);
}
};