diff --git a/class/db.php b/class/db.php index 226b090..0d641ad 100644 --- a/class/db.php +++ b/class/db.php @@ -46,7 +46,7 @@ class db extends mysqli //var_dump($device); $ieeeAddress = $device->ieeeAddress; //print_r($ieeeAddress); - $query = "INSERT INTO logs (device, property, value) VALUES('" . $this->protect($ieeeAddress) . "', '" . $this->protect($property) . "', '" . $this->protect($value) . "')"; + $query = "INSERT INTO logs (device, property, value) VALUES('" . $this->protect($ieeeAddress) . "', '" . $this->protect($property) . "', '" . $this->protect(bool2string($value)) . "')"; echo $query; if (is_numeric($value) and !empty($properties2log[$property])) { diff --git a/db_functions.php b/db_functions.php index cbbc54a..13a5ee8 100644 --- a/db_functions.php +++ b/db_functions.php @@ -63,7 +63,6 @@ function mkDevicesDB($topic, $json, $group=false) fwrite($logFh, "################################START##################################################"); fwrite($logFh, var_export($devices, true)); fwrite($logFh, "################################END##################################################"); - fwrite($logFh, var_export($indexFriendlyNames, true)); logger(DEBUG, _("Devices DB made"), __FILE__ . ":" . __LINE__); //print_r($devices); } @@ -175,7 +174,7 @@ function iterateDevice($topic, $fn, $parentDevice, &$properties, $payloadArray, //echo "PropertyTree ==============> " . $propertyTree . EOL; foreach($payloadArray as $key => $value) { - $oldValue = null; + //$oldValue = null; //echo "key =>"; print_r($key); echo EOL; //echo "value =>"; var_dump($value); echo EOL; //echo "type : " . gettype($value) .EOL; @@ -279,6 +278,7 @@ function changeValue(&$property, $value, &$parentDevice, $propertyTree, $key) //$changed[$fn]["value"] = $value; logger(INFO, sprintf(_("Logging Device property %s, %s"), $propertyTree . $key, bool2string($value)), __FILE__ . ":" . __LINE__); $mohaDB->logProperty($parentDevice, $key, $value, $property["value"]); + logger(DEBUG, sprintf(_("old value was %s, new is %s" ), bool2string($property["value"]), bool2string($value)), __FILE__ . ":" . __LINE__); $property["value"] = $value; if (!empty($property["functions"])) { diff --git a/events.php b/events.php index 550b60f..7fd4441 100644 --- a/events.php +++ b/events.php @@ -8,7 +8,7 @@ function checkEvents() { global $logLevel, $events; $oldLevel = $logLevel; - $loglevel = DEBUG; + $logLevel = DEBUG; $exception = false; foreach ($events as $key => $event) { @@ -104,7 +104,7 @@ function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=fal { global $events, $logLevel; $oldLevel = $logLevel; - $loglevel = DEBUG; + $logLevel = DEBUG; $datetime = new dateTime(); strtolower($unit); switch($unit) @@ -156,7 +156,7 @@ function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=fal $events[$key]->device = & $deviceObject; logger (DEBUG, _('Setting new delay in $events[]'), __FILE__ . ":" . __LINE__); //print_r($events[$key]); - $loglevel = $oldLevel; + $logLevel = $oldLevel; } function removeEvent($deviceObject, $property , $value) diff --git a/hooks/scripts/rdc_chambre_eclairage.php b/hooks/scripts/rdc_chambre_eclairage.php index 7cbf9e0..cf194b4 100644 --- a/hooks/scripts/rdc_chambre_eclairage.php +++ b/hooks/scripts/rdc_chambre_eclairage.php @@ -39,8 +39,8 @@ class rdc_chambre_eclairage extends hook private function send($deviceObject, $state, $delayState = false, $method = MANUAL) { global $devices, $indexDevices; - $msg = array("state" => $state); - if ($deviceObject->properties["state"]["value"] != $state) + $msg = array("state_l1" => $state); + if ($deviceObject->properties["state_l1"]["value"] != $state) { logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__); $deviceObject->payload = $msg; diff --git a/hooks/scripts/rdc_salon_eclairage.php b/hooks/scripts/rdc_salon_eclairage.php index 2c44971..7daca51 100644 --- a/hooks/scripts/rdc_salon_eclairage.php +++ b/hooks/scripts/rdc_salon_eclairage.php @@ -26,32 +26,34 @@ class rdc_salon_eclairage extends hook $lux = $indexDevices[RDC_SALON_LUMINOSITE]; $mvmt = $indexDevices[RDC_SALON_MVMT]; $mvmt2 = $indexDevices[RDC_SALON_MVMT2]; + logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__); + switch($param) { case "occupancy": - logger(DEBUG, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__); + logger(INFO, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__); //print_r(getValue(RDC_SALON_LUMINOSITE, "illuminance_lux")); if ($value == ON and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min) { - logger(DEBUG, _("setting to ON"), __FILE__ . ":" . __LINE__); + logger(INFO, _("setting to ON"), __FILE__ . ":" . __LINE__); $this->send($deviceTarget, "ON", null, AUTO); removeEvent($deviceTarget, "state", "OFF"); }elseif ($value == OFF) { - logger(DEBUG, _("Value is OFF"), __FILE__ . ":" . __LINE__); + logger(INFO, _("Value is OFF"), __FILE__ . ":" . __LINE__); if (getValue(RDC_SALON_MVMT, "occupancy") == OFF and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF)) { - logger(DEBUG, _("Setting to OFF"), __FILE__ . ":" . __LINE__); + logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__); setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true); //$this->send($deviceTarget, "ON", "OFF", AUTO); } } break; case "contact": - logger(DEBUG, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__); + logger(INFO, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__); if ($value == false and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min and getValue($deviceTarget->ieeeAddress, "state") == "OFF") { - logger(DEBUG, _("Door is open and illumance < min"), __FILE__ . ":" . __LINE__); + logger(INFO, _("Door is open and illumance < min"), __FILE__ . ":" . __LINE__); if (getValue(RDC_SALON_MVMT, "occupancy") == ON or getValue(RDC_SALON_MVMT2, "occupancy") == ON) { $this->send($deviceTarget, "ON", null, AUTO); @@ -62,10 +64,10 @@ class rdc_salon_eclairage extends hook } break; case "illuminance_lux": - logger(DEBUG, _("CASE : Illuminance"), __FILE__ . ":" . __LINE__); + logger(INFO, _("CASE : Illuminance"), __FILE__ . ":" . __LINE__); if ($value >= $this->luminance_max) { - logger(DEBUG, _("illuminace is > to max"), __FILE__ . ":" . __LINE__); + logger(INFO, _("illuminace is > to max"), __FILE__ . ":" . __LINE__); //$this->send($deviceTarget, "OFF", null, AUTO); //removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF"); if (searchEvent($deviceTarget, "state", "OFF") === false) @@ -74,7 +76,7 @@ class rdc_salon_eclairage extends hook } }elseif ($value <= $this->luminance_min and (getValue(RDC_SALON_MVMT, "occupancy") == ON OR getValue(RDC_SALON_MVMT2,"occupancy") == ON)) { - logger(DEBUG, _("illuminance < min and movement detected"), __FILE__ . ":" . __LINE__); + logger(INFO, _("illuminance < min and movement detected"), __FILE__ . ":" . __LINE__); $this->send($deviceTarget, "ON", null, AUTO); } break; diff --git a/webserver/cmd_functions.php b/webserver/cmd_functions.php index 7de042d..d9299bb 100644 --- a/webserver/cmd_functions.php +++ b/webserver/cmd_functions.php @@ -112,7 +112,7 @@ function webBrowse($socket, $argList) function iterateProperty($property, $value, &$response, $tab="") { - $tab .= "   "; + $tab .= "     "; if (is_array($value) or is_object($value)) { logger(DEBUG, _("is object or array"), __FILE__ . ":" . __LINE__ );