1
0

added custom script plus some debugging

This commit is contained in:
2022-01-03 21:11:52 +01:00
parent d79463fbd4
commit 5224d00d5a
10 changed files with 173 additions and 55 deletions

View File

@ -3,6 +3,10 @@
//Constants
define( "EOL", "\n");
define("Z2M", "zigbee2mqtt");
define("ON", 1);
define("OFF", 0);
define("AUTO", 0);
define("MANUAL", 1);
declare(ticks = 1);
@ -26,6 +30,7 @@ $connected = false; // connected to MQTT server
$included = false; // flag indicate scripts are loaded
$nSubscribed = 0; // Number of topics subsribed
$logFh = null; // filehandle of log file
$curlErr = 0; // Number of errors returned by curl
// topics definition
$topics["zigbee2mqtt"] = new topic;
@ -41,15 +46,16 @@ if (!init()) exit(1);
$client = new Mosquitto\Client();
// log levels
define( "DEBUG", $client::LOG_DEBUG);
define( "INFO", $client::LOG_INFO);
define( "NOTICE", $client::LOG_NOTICE);
define( "WARNING", $client::LOG_WARNING);
define( "ERROR", $client::LOG_ERR);
define( "DEBUG", $client::LOG_DEBUG); // => 16
define( "INFO", $client::LOG_INFO); // => 1
define( "NOTICE", $client::LOG_NOTICE); // => 2
define( "WARNING", $client::LOG_WARNING); // => 4
define( "ERROR", $client::LOG_ERR); // => 8
define( "ALL", DEBUG | INFO | NOTICE | WARNING | ERROR);
$logLevel = DEBUG;
$logLevel = ALL;
$notificationLevel = WARNING | ERROR;
require "utils.php";
require "mqtt_functions.php";
require "events.php";
@ -80,7 +86,7 @@ foreach($topics as $name => $topic)
$mids[$topic->mid] = $name;
$topic->status = false;
}
$oneshot = false;
while (true)
{
$client->loop();
@ -99,6 +105,10 @@ while (true)
}
}elseif($dbInit == 2 and $included)
{
if ($oneshot === false) // execute once initialization finished
{
$oneshot = true;
}
checkEvents();
}
}
@ -151,14 +161,7 @@ function endMoha()
{
global $topics, $nSubscribed ,$client, $logFh, $connected;
$x = 0;
/*foreach($topics as $topic => $object)
{
if ($object->status)
{*/
$mid = $client->unsubscribe("#");
/*$mids[$mid] = $topic;
}
}*/
$mid = $client->unsubscribe("#");
while ($connected)
{