1
0

debbuging presence

This commit is contained in:
Daniel Tartavel 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") function apiDashboard($socket, $n="Général")
{ {
global $dashboards, $indexDevices; global $dashboards, $indexDevices, $properties2log;
require_once "apiserver/javascript.php"; require_once "apiserver/javascript.php";
logger(DEBUG, _("apiDashboard function"), __FILE__ . ":" . __LINE__); logger(DEBUG, _("apiDashboard function"), __FILE__ . ":" . __LINE__);
$response = insertJavascript(); $response = insertJavascript();
@ -14,9 +14,10 @@ function apiDashboard($socket, $n="Général")
{ {
if (array_key_exists($array[0], $indexDevices)) if (array_key_exists($array[0], $indexDevices))
{ {
$device = $indexDevices[$array[0]]; $ieeeAddress = $array[0];
$device = $indexDevices[$ieeeAddress];
$property = $array[1]; $property = $array[1];
if (array_key_exists($array[1], $device->properties)) if (array_key_exists($property, $device->properties))
{ {
$propertyObject = $device->properties[$property]; $propertyObject = $device->properties[$property];
$value = $propertyObject["value"]; $value = $propertyObject["value"];
@ -29,17 +30,18 @@ function apiDashboard($socket, $n="Général")
{ {
logger(DEBUG, _("Write Access OK ") . ($propertyObject["access"] & 2), __FILE__ . ":" . __LINE__); logger(DEBUG, _("Write Access OK ") . ($propertyObject["access"] & 2), __FILE__ . ":" . __LINE__);
$response .= "     " . displayChoice($device, $property, $value); $response .= "     " . displayChoice($device, $property, $value);
$response .= "   " . displayMethod($device, $property); $response .= "   " . displayMethod($device, $property) . EOL;
} }
if(($propertyObject["access"] & 4)) if(($propertyObject["access"] & 4))
{ {
logger(DEBUG, _("can get value") . ($propertyObject["access"] & 4), __FILE__ . ":" . __LINE__); 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 }else
{ {
$response .= $value; $response .= $value;
} }
$response .= EOLH;
//$response .= EOLH;
}else }else
{ {
$response .= bool2string(_($value)); $response .= bool2string(_($value));
@ -48,9 +50,11 @@ function apiDashboard($socket, $n="Général")
$response .= $propertyObject["unit"]; $response .= $propertyObject["unit"];
logger(DEBUG, _("unit = ") . $unit, __FILE__ . ":" . __LINE__); 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 }else
{ {
logger(ERROR, _("Property does not exists"), __FILE__ . ":" . __LINE__); 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__); logger(ERROR, _("Device does not exists"), __FILE__ . ":" . __LINE__);
} }
$response .= EOLH;
} }
}else }else
{ {
@ -124,6 +129,7 @@ function displayChoice($device, $propertyName, $value)
break; break;
default: default:
logger(DEBUG, "type of property not recognized:" . $propertyObject["type"] , __FILE__ . ":" . __LINE__); logger(DEBUG, "type of property not recognized:" . $propertyObject["type"] , __FILE__ . ":" . __LINE__);
break;
} }
return $formHTML; return $formHTML;

View File

@ -35,13 +35,16 @@ $deviceTable = array(
"0x00158d0001a0028c" => "ETAGE_BUREAU_FENETRE", "0x00158d0001a0028c" => "ETAGE_BUREAU_FENETRE",
"0x14b457fffe42a2c9" => "ETAGE_BUREAU_PANNEAU", "0x14b457fffe42a2c9" => "ETAGE_BUREAU_PANNEAU",
"0x842e14fffe8e3b67" => "ETAGE_BUREAU_ECLAIRAGE_INTER", "0x842e14fffe8e3b67" => "ETAGE_BUREAU_ECLAIRAGE_INTER",
"0x60a423fffe372f74" => "ETAGE_BUREAU_TEMP",
"0x00158d0001de080d" => "ETAGE_CHAMBRE_FENETRE", "0x00158d0001de080d" => "ETAGE_CHAMBRE_FENETRE",
"0x60a423fffe373170" => "ETAGE_CHAMBRE_TEMP",
"0x00124b00251ea4a7" => "ETAGE_CUISINE_PLAN_TRAVAIL_INTER", "0x00124b00251ea4a7" => "ETAGE_CUISINE_PLAN_TRAVAIL_INTER",
"0x680ae2fffe403f22" => "ETAGE_CUISINE_PLAN_TRAVAIL_ECLAIRAGE", "0x680ae2fffe403f22" => "ETAGE_CUISINE_PLAN_TRAVAIL_ECLAIRAGE",
"0xbc33acfffe65621b" => "ETAGE_CUISINE_PLAN_TRAVAIL_SPOT", "0xbc33acfffe65621b" => "ETAGE_CUISINE_PLAN_TRAVAIL_SPOT",
"1" => "ETAGE_CUISINE_PLAN_TRAVAIL_GROUPE_ECLAIRAGE", "1" => "ETAGE_CUISINE_PLAN_TRAVAIL_GROUPE_ECLAIRAGE",
"0x00158d00019f370e" => "ETAGE_PORTE_ENTREE", "0x00158d00019f370e" => "ETAGE_PORTE_ENTREE",
"0x00158d00044fd579" => "ETAGE_SALON_FENETRE", "0x00158d00044fd579" => "ETAGE_SALON_FENETRE",
"0x00158d0005471cd1" => "ETAGE_SALON_TEMP",
"0x00158d0004621e1f" => "ETAGE_CUISINE_FENETRE", "0x00158d0004621e1f" => "ETAGE_CUISINE_FENETRE",
"0x00158d0001ddefe1" => "ETAGE_PORTE_FENETRE", "0x00158d0001ddefe1" => "ETAGE_PORTE_FENETRE",
"0x086bd7fffe5aeab6" => "RDC_CHAMBRE_AMBIANCE", "0x086bd7fffe5aeab6" => "RDC_CHAMBRE_AMBIANCE",
@ -53,11 +56,13 @@ $deviceTable = array(
"0x842e14fffe9be0fc" => "RDC_STORE", "0x842e14fffe9be0fc" => "RDC_STORE",
"0xa4c138165e31c0e8" => "RDC_STORE_VIBRATION", "0xa4c138165e31c0e8" => "RDC_STORE_VIBRATION",
"0x04cf8cdf3c7b3d64" => "RDC_EXTERIEUR_LUMINOSITE", "0x04cf8cdf3c7b3d64" => "RDC_EXTERIEUR_LUMINOSITE",
"0x04cf8cdf3c7b38d1" => "RDC_FACADE_LUMINOSITE",
"0x483fda53cbcb" => "METEO" "0x483fda53cbcb" => "METEO"
); );
foreach($deviceTable as $device => $name) foreach($deviceTable as $device => $name)
{ {
define($name, $device); define($name, $device);
} }

View File

@ -2,6 +2,7 @@
$macAddresses = array( $macAddresses = array(
"E8:78:29:C2:79:22" => "Daniel", "E8:78:29:C2:79:22" => "Daniel",
//"84:CF:BF:8E:E6:A6" => "daniel",
"D0:9C:7A:DA:8E:D8" => "Maryclaire", "D0:9C:7A:DA:8E:D8" => "Maryclaire",
"FA:61:B1:D8:3C:D4" => "Maryclaire", "FA:61:B1:D8:3C:D4" => "Maryclaire",
"26:4D:40:5F:1E:10" => "Terence" "26:4D:40:5F:1E:10" => "Terence"

View File

@ -29,25 +29,30 @@ if (empty($indexIeeeAddress))
{ {
if ( array_key_exists($value["device"], $indexIeeeAddress)) if ( array_key_exists($value["device"], $indexIeeeAddress))
{ {
$devicesList[$value["device"]]["fn"] = $indexIeeeAddress[$value["device"]]; $fn = $indexIeeeAddress[$value["device"]];
$devicesList[$value["device"]][] = $value["property"]; $devicesList[$fn]["ieeeAddress"] = $value["device"];
$devicesList[$fn]["properties"][] = $value["property"];
} }
} }
ksort($devicesList, SORT_STRING ); ksort($devicesList, SORT_NATURAL | SORT_FLAG_CASE );
//$devicesList = array_intersect_key($indexIeeeAddress, $tmp); //$devicesList = array_intersect_key($indexIeeeAddress, $tmp);
//print_r($devicesList); //print_r($devicesList);
foreach($devicesList as $ieeeAddress => $array) foreach($devicesList as $fn => $array)
{ {
print '<optgroup label="' . $array["fn"] . '">'; print '<optgroup label="' . $fn . '">';
foreach($array as $key => $property) $ieeeAddress = $array["ieeeAddress"];
if (array_key_exists("properties", $array))
{ {
if ($key != "fn") foreach($array["properties"] as $property)
{ {
print '<option value="' . $ieeeAddress . '|' . $array["fn"] . '|' . $property . '">' . $property . '</option>' . EOL; print '<option value="' . $ieeeAddress . '|' . $fn . '|' . $property . '">' . $property . '</option>' . EOL;
}
} }
print '</optgroup>' . EOL; print '</optgroup>' . EOL;
}else
{
echo _("Erreur: la clé de tableau 'properties' n'existe pas ") . __LINE__ . EOLH;
}
} }
print "</select>" . EOLH; print "</select>" . EOLH;
print '<input type="date" name="startDate">' . EOLH; print '<input type="date" name="startDate">' . EOLH;

View File

@ -0,0 +1,15 @@
<?php
require_once "header.php";
require_once "config.php";
require_once $mohaPath . "/constants.php";
print '<form method="GET" action="display_stats.php">';
foreach ($_GET as $key => $value)
{
print '<input type=hidden name=' . $key . ' value=' . $value . ">";
}
print '<input type="date" name="startDate">' . EOLH;
print '<input type="date" name="endDate">' . EOLH;
print '<input type="submit" value="Afficher les statistiques">';
print "</form>" . EOL;
?>