1
0

- lots of debugging

- beginning to add graphical stats
- beginning to add device by type
- added a dashboard "etage"
- begining to add notification to multiple recipients in freemobile hook
This commit is contained in:
2022-03-28 00:40:34 +02:00
parent 80234fc505
commit 0d35b1ff3f
24 changed files with 491 additions and 205 deletions

View File

@ -132,7 +132,7 @@ function listHooks($dir, &$hookList)
function endMoha()
{
global $testMode, $devices, $topics, $nSubscribed ,$client, $logFh, $connected, $dataPath;
global $testMode, $devices, $topics, $events, $nSubscribed ,$client, $logFh, $connected, $dataPath;
$x = 0;
logger(WARNING, _("moha is ending"), __FILE__ . ":" . __LINE__);
@ -144,6 +144,10 @@ function endMoha()
{
logger(ERROR, _("Can not store topics db" ), __FILE__ . ":" . __LINE__);
}
if (storeDB($events, $dataPath . "events.db") === false)
{
logger(ERROR, _("Can not store events db" ), __FILE__ . ":" . __LINE__);
}
if($testMode) file_put_contents($dataPath . "moha.devices", var_export($devices, true));
if ($connected)
{
@ -177,10 +181,10 @@ if (is_readable($configDir . "/devices_constants.php"))
{
include $configDir . "/devices_constants.php";
//echo "hooklist"; print_r($hooksList); echo EOL;
logger(INFO, sprintf(_("%s/devices_constants.define found, so it has been included :-)"), $configDir), __FILE__ . ":" . __LINE__, false);
logger(INFO, sprintf(_("%s/devices_constants.php found, so it has been included :-)"), $configDir), __FILE__ . ":" . __LINE__, false);
}else
{
logger(WARNING, sprintf(_("%s/devices_constants.define not found, so not included :-)"), $configDir), __FILE__ . ":" . __LINE__, false);
logger(WARNING, sprintf(_("%s/devices_constants.php not found, so not included :-)"), $configDir), __FILE__ . ":" . __LINE__, false);
}
logger(DEBUG, _("requiring php modules"), __FILE__ . ":" . __LINE__);
@ -224,24 +228,42 @@ if (!empty($hooksList)) // some hooks to include if hooklist is not empty
logger(DEBUG, _("Loading stored topics datas from ") . $dataPath . "topics.db", __FILE__ . ":" . __LINE__);
if (file_exists($dataPath . "topics.db"))
{
if (($topics = loadDB($dataPath . "topics.db")) === false)
if (($db = loadDB($dataPath . "topics.db")) === false)
{
logger(ERROR, _("Can not load topics db"), __FILE__ . ":" . __LINE__);
}else
{
$topics = $db;
}
}
logger(DEBUG, _("Loading stored devices datas from ") . $dataPath . "devices.db", __FILE__ . ":" . __LINE__);
if (file_exists($dataPath . "devices.db"))
{
if (($devices = loadDB($dataPath . "devices.db")) === false)
if (($db = loadDB($dataPath . "devices.db")) === false)
{
logger(ERROR, _("Can not load devices db"), __FILE__ . ":" . __LINE__);
}else
{
$devices = $db;
mkIndexes();
}
}
logger(DEBUG, _("Loading stored events datas from ") . $dataPath . "events.db", __FILE__ . ":" . __LINE__);
if (file_exists($dataPath . "events.db"))
{
if (($db = loadDB($dataPath . "events.db")) === false)
{
logger(ERROR, _("Can not load events db"), __FILE__ . ":" . __LINE__);
}else
{
$events = $db;
}
}
// Program start
logger(DEBUG, _("Program start"), __FILE__ . ":" . __LINE__, false);
$client = new Mosquitto\Client();