1
0

- added values in celsius degree and in km/h in pws2mqtt

- debug of hooks
-added webserver.php
This commit is contained in:
2022-01-27 18:41:16 +01:00
parent fc4eaf2238
commit 1361cb9395
13 changed files with 214 additions and 57 deletions

View File

@ -1,21 +1,19 @@
<?php
$title = "moha";
$testMode = true;
$webServerIsActive = true;
cli_set_process_title($title);
file_put_contents("/proc/".getmypid()."/comm",$title);
declare(ticks = 1);
$testMode = true;
$webServerIsActive = true;
require "constants.php";
declare(ticks = 1);
$listProperties = array("powerSource" => "batterie");
$listPropertiesKeys = array("property");
//global variables
$logLevel = INFO | NOTICE | WARNING | ERROR | ALERT; //ALL;
$logLevel = ALL; // INFO | NOTICE | WARNING | ERROR | ALERT; //ALL;
$notificationLevel = ALERT | ERROR;
$topics = array(); // list of topics
$mids = array(); // list of message IDs
@ -61,7 +59,7 @@ function notify($message)
function logger($level, $log, $notif = true)
{
global $logFh, $logLevel, $notificationLevel, $logLevels;
$logString = date("c") . ' ' . $logLevels[$level] . " : $log";
$logString = date("c") . ' ' . $logLevels[$level] . " " . __FILE__ . ":" . __LINE__ . " : " . $log;
if ($level & $logLevel)
{
fwrite($logFh, $logString . EOL);
@ -112,7 +110,7 @@ function listHooks($dir, &$hookList)
function endMoha()
{
global $devices, $topics, $nSubscribed ,$client, $logFh, $connected;
global $testMode, $devices, $topics, $nSubscribed ,$client, $logFh, $connected;
$x = 0;
storeDB($devices, "/usr/share/moha/moha.db");
if($testMode) file_put_contents("moha.devices", print_r($devices, true));
@ -149,6 +147,7 @@ require $configDir . "/properties2log.php";
require "mqtt_functions.php";
require "events.php";
require "db_functions.php";
require "webserver.php";
//logger(DEBUG, _('assigning variable $client to mosquitto class "client"'), false);
//$client = new Mosquitto\Client();
@ -263,6 +262,7 @@ while (true)
logger(DEBUG,_("All hooks initialized"));
}
checkEvents();
askWebServer($read);
}
}