1
0

- debugage\n- version avec plugins fonctionnels

This commit is contained in:
daniel Tartavel 2022-02-25 20:42:33 +01:00
parent f6b7b9e664
commit a29aa9b653
6 changed files with 20 additions and 18 deletions

View File

@ -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]))
{

View File

@ -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"]))
{

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -112,7 +112,7 @@ function webBrowse($socket, $argList)
function iterateProperty($property, $value, &$response, $tab="")
{
$tab .= "&nbsp;&nbsp;&nbsp;";
$tab .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
if (is_array($value) or is_object($value))
{
logger(DEBUG, _("is object or array"), __FILE__ . ":" . __LINE__ );