a lot of debug
This commit is contained in:
@ -24,28 +24,35 @@ class hook
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
global $devices;
|
||||
global $devices, $devicesRequest;
|
||||
static $requestflag = 0;
|
||||
$result = true;
|
||||
// assigne the function to the sensors devices
|
||||
if ($this->active === true)
|
||||
{
|
||||
foreach ($this->devicelist as $ieeeAddress => $property)
|
||||
{
|
||||
if (array_key_exists($ieeeAddress, $devices))
|
||||
if (array_key_exists($ieeeAddress, $indexDevices))
|
||||
{
|
||||
logger(DEBUG, _("Device: ") . $ieeeAddress, __FILE__ . ":" . __LINE__);
|
||||
if ($this->propertyInitialized[$ieeeAddress][$property] === false)
|
||||
if (!array_key_exists($this->hookName, $indexDevices[$ieeeAddress]->properties[$property]["functions"]))
|
||||
{
|
||||
logger(DEBUG, _("Trying to store callback"), __FILE__ . ":" . __LINE__);
|
||||
if (array_key_exists("functions", $indexDevices[$ieeeAddress]->properties[$property]))
|
||||
if (array_key_exists($property, $indexDevices[$ieeeAddress]->properties))
|
||||
{
|
||||
$indexDevices[$ieeeAddress]->properties[$property]["functions"][$this->hookName] = array($this,"callback");
|
||||
$this->propertyInitialized[$ieeeAddress][$property] = true;
|
||||
logger(DEBUG, sprintf(_("Property '%s' of %s is initialized with callback"), $property, $indexDevices[$ieeeAddress]->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
logger(DEBUG, _("Trying to store callback"), __FILE__ . ":" . __LINE__);
|
||||
if (array_key_exists("functions", $indexDevices[$ieeeAddress]->properties[$property]))
|
||||
{
|
||||
$indexDevices[$ieeeAddress]->properties[$property]["functions"][$this->hookName] = array($this,"callback");
|
||||
logger(DEBUG, sprintf(_("Property '%s' of %s is initialized with callback"), $property, $indexDevices[$ieeeAddress]->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
|
||||
}else
|
||||
{
|
||||
logger(WARNING, sprintf(_("Hook %s can not initialize Property '%s' of device %s"), $this->hookName, $property, $ieeeAddress), __FILE__ . ":" . __LINE__);
|
||||
$result = false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
logger(WARNING, sprintf(_("Hook %s can not initialize Property '%s' of device %s"), $this->hookName, $property, $ieeeAddress), __FILE__ . ":" . __LINE__);
|
||||
logger(WARNING, sprintf(_("Hook %s can not initialize Property '%s' of device %s : property does not exists"), $this->hookName, $property, $indexDevices[$ieeeAddress]->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$result = false;
|
||||
}
|
||||
}else
|
||||
@ -55,6 +62,16 @@ class hook
|
||||
}else
|
||||
{
|
||||
logger(ERROR, $ieeeAddress . (" does not exists"), __FILE__ . ":" . __LINE__);
|
||||
if ($devicesRequest === false)
|
||||
{
|
||||
publish("zigbee2mqtt", array("bridge/devices" => ""), "get");
|
||||
$devicesRequest = true;
|
||||
}elseif ($requestflag++ > 30)
|
||||
{
|
||||
$requestflag = 0;
|
||||
}
|
||||
|
||||
$result = false;
|
||||
mkIndexes();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user