1
0

récupération après crash

This commit is contained in:
2022-12-05 12:23:43 +01:00
parent 559039b5e3
commit a27db71327
22 changed files with 300 additions and 147 deletions

View File

@ -90,13 +90,16 @@ function apiServer($read)
logger(DEBUG, _("command is ") . $command, __FILE__ . ":" . __LINE__);
switch($command)
{
case "?":
case "help":
htmlSend($spawn, help($argList));
break;
case "dashboard":
apiDashboard($spawn, $argList["dashboard"]);
break;
case "browse":
logger(DEBUG, _("Browsing"), __FILE__ . ":" . __LINE__);
apiBrowse($spawn, $argList);
//return true;
break;
case "get":
logger(DEBUG, _("GET reached"), __FILE__ . ":" . __LINE__);
@ -116,8 +119,8 @@ function apiServer($read)
htmlSend($spawn, apiNotify($argList));
logger(DEBUG, print_r($monitored, true), __FILE__ . ":" . __LINE__);
break;
case "type":
logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__);
//case "type":
//logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__);
//htmlSend($spawn, apiDisplayByType($argList));
case "enable":
logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__);
@ -155,6 +158,10 @@ function apiServer($read)
logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__);
htmlSend($spawn, test($argList));
break;
case "unavailable":
logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__);
htmlSend($spawn, unavailable($argList));
break;
default:
if (is_numeric(array_key_first($argList)))
{

View File

@ -606,22 +606,86 @@ function whoIsPresent($argList)
function test()
{
global $hooks;
global $scripts;
$portes = array();
$msg = "";
$msg = _("<b>Opened doors:</b>") . EOLH;
logger(DEBUG, _("Testing doors") , __FILE__ . ":" . __LINE__);
echo "testing doors";
$portes = $hooks["test_portes"]->testPortes();
$portes = $scripts["test_portes"]->testPortes();
if (!empty($portes))
{
$msg = _("Opened doors:") . EOLH;
foreach($portes as $value)
{
$msg .= $value . EOL;
}
}else
{
$msg .= _("No doors opened");
}
return $msg;
}
function unavailable()
{
global $indexDevices;
$msg = _("<b>List of unavailable devices:</b>") . EOLH;
foreach($indexDevices as $ieeeAddress => $device)
{
if (key_exists("availability", $device->properties))
{
if ($device->properties["availability"]["value"] == "offline")
{
$msg .= $device->friendlyName . EOLH;
}
}
}
return $msg;
}
function help()
{
$msg = "<table>";
$msg .= "<tr><td><b>Commands</b></td><td><b>Description and Parameters</b></td>";
$msg .= "<tr><td>browse</td><td>Browse device List<br>fn=friendlyname topic=topicname</td></tr>";
$msg .= "<tr><td>dashboard</td><td>Display dashboards<br>Name of the dashboard</td></tr>";
// $msg .= "<tr><td>deletedevice</td><td></td></tr>";
$msg .= "<tr><td>disable</td><td>Disable a hook<br>name of the hook</td></tr>";
$msg .= "<tr><td>dump</td><td>Display the content of a variable<br>variable name</td></tr>";
$msg .= "<tr><td>enable</td><td>Enable a hook<br>name of the hook</td></tr>";
$msg .= "<tr><td>friendlyname</td><td>Return friendlyname from ieeeadress<br>ieeeadress of device</td></tr>";
$msg .= "<tr><td>get</td><td>Get value of the property of a device<br>fn=friendlyname, topic=topic name, property=property name</td></tr>";
$msg .= "<tr><td>ispresent</td><td>Return the presence of a person<br>Name of the person</td></tr>";
$msg .= "<tr><td>notify</td><td>Notify when property condition and value<br>topic, fn, property, condition, value</td></tr>";
// $msg .= "<tr><td>type</td><td></td></tr>";
$msg .= "<tr><td>present</td><td>List persons present</td></tr>";
$msg .= "<tr><td>print</td><td>Dump the content of a variable<br>variable name</td></tr>";
$msg .= "<tr><td>property</td><td>Display all devices with given property<br>Property to display</td></tr>";
$msg .= "<tr><td>set</td><td>Set value of the property of a device<br>fn=friendlyname, topic=topic name, property=property name</td></tr>";
$msg .= "<tr><td>test</td><td>Return all opened doors</td></tr>";
$msg .= "<tr><td>unavailable</td><td>Displey all unavalaible devices</td></tr>";
$msg .= "<tr><td>verbose</td><td>Enable or disable log levels<br>" . htmlDisplayLoglevels() . "</td></tr>";
$msg .= "</table>";
return $msg;
}
function htmlDisplayLoglevels()
{
global $logLevels;
$text = "";
$flag = false;
foreach($logLevels as $level)
{
if ($flag === true)
{
$text .= " ,";
}else
{
$flag = true;
}
$text .= $level;
}
return $text;
}
?>