1
0

debbuging presence

This commit is contained in:
2022-09-09 16:52:26 +02:00
parent 4acb2992ca
commit c00b766cc4
5 changed files with 49 additions and 17 deletions

View File

@ -3,7 +3,7 @@ require_once "events.php";
function apiDashboard($socket, $n="Général")
{
global $dashboards, $indexDevices;
global $dashboards, $indexDevices, $properties2log;
require_once "apiserver/javascript.php";
logger(DEBUG, _("apiDashboard function"), __FILE__ . ":" . __LINE__);
$response = insertJavascript();
@ -14,9 +14,10 @@ function apiDashboard($socket, $n="Général")
{
if (array_key_exists($array[0], $indexDevices))
{
$device = $indexDevices[$array[0]];
$ieeeAddress = $array[0];
$device = $indexDevices[$ieeeAddress];
$property = $array[1];
if (array_key_exists($array[1], $device->properties))
if (array_key_exists($property, $device->properties))
{
$propertyObject = $device->properties[$property];
$value = $propertyObject["value"];
@ -29,17 +30,18 @@ function apiDashboard($socket, $n="Général")
{
logger(DEBUG, _("Write Access OK ") . ($propertyObject["access"] & 2), __FILE__ . ":" . __LINE__);
$response .= "     " . displayChoice($device, $property, $value);
$response .= "   " . displayMethod($device, $property);
$response .= "   " . displayMethod($device, $property) . EOL;
}
if(($propertyObject["access"] & 4))
{
logger(DEBUG, _("can get value") . ($propertyObject["access"] & 4), __FILE__ . ":" . __LINE__);
$response .= '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyObject["name"] . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "','" . $device->friendlyName . "','" . $propertyObject["name"] . "')\">";
$response .= '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyObject["name"] . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "','" . $device->friendlyName . "','" . $propertyObject["name"] . "')\">" . EOL;
}else
{
$response .= $value;
}
$response .= EOLH;
//$response .= EOLH;
}else
{
$response .= bool2string(_($value));
@ -48,9 +50,11 @@ function apiDashboard($socket, $n="Général")
$response .= $propertyObject["unit"];
logger(DEBUG, _("unit = ") . $unit, __FILE__ . ":" . __LINE__);
}
$response .= EOLH;
}
if (array_key_exists($property, $properties2log))
{
$response .= '&nbsp;&nbsp;<a href="http://192.168.1.253/moha/intervalDate.php?device=' . $ieeeAddress . '%7C' . $device->friendlyName . '%7C' . $property . '">Stats</a>';
}
}else
{
logger(ERROR, _("Property does not exists"), __FILE__ . ":" . __LINE__);
@ -59,6 +63,7 @@ function apiDashboard($socket, $n="Général")
{
logger(ERROR, _("Device does not exists"), __FILE__ . ":" . __LINE__);
}
$response .= EOLH;
}
}else
{
@ -124,6 +129,7 @@ function displayChoice($device, $propertyName, $value)
break;
default:
logger(DEBUG, "type of property not recognized:" . $propertyObject["type"] , __FILE__ . ":" . __LINE__);
break;
}
return $formHTML;