From c00b766cc4315a006dd5bbc38048c799d5af8e6a Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Fri, 9 Sep 2022 16:52:26 +0200 Subject: [PATCH] debbuging presence --- apiserver/cmd_functions.php | 22 ++++++++++++++-------- config/devices_constants.php | 5 +++++ config/liste_telephones.php | 1 + webserver/index.php | 23 ++++++++++++++--------- webserver/intervalDate.php | 15 +++++++++++++++ 5 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 webserver/intervalDate.php diff --git a/apiserver/cmd_functions.php b/apiserver/cmd_functions.php index a6052fa..2e70761 100644 --- a/apiserver/cmd_functions.php +++ b/apiserver/cmd_functions.php @@ -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 .= 'friendlyName . "/" . $propertyObject["name"] . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "','" . $device->friendlyName . "','" . $propertyObject["name"] . "')\">"; + $response .= '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 .= '  Stats'; + } }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; diff --git a/config/devices_constants.php b/config/devices_constants.php index 389aea8..58c7a14 100644 --- a/config/devices_constants.php +++ b/config/devices_constants.php @@ -35,13 +35,16 @@ $deviceTable = array( "0x00158d0001a0028c" => "ETAGE_BUREAU_FENETRE", "0x14b457fffe42a2c9" => "ETAGE_BUREAU_PANNEAU", "0x842e14fffe8e3b67" => "ETAGE_BUREAU_ECLAIRAGE_INTER", + "0x60a423fffe372f74" => "ETAGE_BUREAU_TEMP", "0x00158d0001de080d" => "ETAGE_CHAMBRE_FENETRE", + "0x60a423fffe373170" => "ETAGE_CHAMBRE_TEMP", "0x00124b00251ea4a7" => "ETAGE_CUISINE_PLAN_TRAVAIL_INTER", "0x680ae2fffe403f22" => "ETAGE_CUISINE_PLAN_TRAVAIL_ECLAIRAGE", "0xbc33acfffe65621b" => "ETAGE_CUISINE_PLAN_TRAVAIL_SPOT", "1" => "ETAGE_CUISINE_PLAN_TRAVAIL_GROUPE_ECLAIRAGE", "0x00158d00019f370e" => "ETAGE_PORTE_ENTREE", "0x00158d00044fd579" => "ETAGE_SALON_FENETRE", + "0x00158d0005471cd1" => "ETAGE_SALON_TEMP", "0x00158d0004621e1f" => "ETAGE_CUISINE_FENETRE", "0x00158d0001ddefe1" => "ETAGE_PORTE_FENETRE", "0x086bd7fffe5aeab6" => "RDC_CHAMBRE_AMBIANCE", @@ -53,11 +56,13 @@ $deviceTable = array( "0x842e14fffe9be0fc" => "RDC_STORE", "0xa4c138165e31c0e8" => "RDC_STORE_VIBRATION", "0x04cf8cdf3c7b3d64" => "RDC_EXTERIEUR_LUMINOSITE", + "0x04cf8cdf3c7b38d1" => "RDC_FACADE_LUMINOSITE", "0x483fda53cbcb" => "METEO" ); foreach($deviceTable as $device => $name) { + define($name, $device); } diff --git a/config/liste_telephones.php b/config/liste_telephones.php index 9e0650f..36a878e 100644 --- a/config/liste_telephones.php +++ b/config/liste_telephones.php @@ -2,6 +2,7 @@ $macAddresses = array( "E8:78:29:C2:79:22" => "Daniel", +//"84:CF:BF:8E:E6:A6" => "daniel", "D0:9C:7A:DA:8E:D8" => "Maryclaire", "FA:61:B1:D8:3C:D4" => "Maryclaire", "26:4D:40:5F:1E:10" => "Terence" diff --git a/webserver/index.php b/webserver/index.php index bd2d5dd..fdbd124 100644 --- a/webserver/index.php +++ b/webserver/index.php @@ -29,25 +29,30 @@ if (empty($indexIeeeAddress)) { if ( array_key_exists($value["device"], $indexIeeeAddress)) { - $devicesList[$value["device"]]["fn"] = $indexIeeeAddress[$value["device"]]; - $devicesList[$value["device"]][] = $value["property"]; + $fn = $indexIeeeAddress[$value["device"]]; + $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); //print_r($devicesList); - foreach($devicesList as $ieeeAddress => $array) + foreach($devicesList as $fn => $array) { - print ''; - foreach($array as $key => $property) + print ''; + $ieeeAddress = $array["ieeeAddress"]; + if (array_key_exists("properties", $array)) { - if ($key != "fn") + foreach($array["properties"] as $property) { - print '' . EOL; + print '' . EOL; } + print '' . EOL; + }else + { + echo _("Erreur: la clé de tableau 'properties' n'existe pas ") . __LINE__ . EOLH; } - print '' . EOL; } print "" . EOLH; print '' . EOLH; diff --git a/webserver/intervalDate.php b/webserver/intervalDate.php new file mode 100644 index 0000000..b87e099 --- /dev/null +++ b/webserver/intervalDate.php @@ -0,0 +1,15 @@ +'; + foreach ($_GET as $key => $value) + { + print '' . EOLH; + print '' . EOLH; + print ''; + print "" . EOL; + +?>