- debugage\n- version avec plugins fonctionnels
This commit is contained in:
		| @@ -46,7 +46,7 @@ class db extends mysqli | |||||||
| 			//var_dump($device); | 			//var_dump($device); | ||||||
| 			$ieeeAddress = $device->ieeeAddress; | 			$ieeeAddress = $device->ieeeAddress; | ||||||
| 			//print_r($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; | 			echo $query; | ||||||
| 			if (is_numeric($value) and !empty($properties2log[$property])) | 			if (is_numeric($value) and !empty($properties2log[$property])) | ||||||
| 			{ | 			{ | ||||||
|   | |||||||
| @@ -63,7 +63,6 @@ function mkDevicesDB($topic, $json, $group=false) | |||||||
| 	fwrite($logFh, "################################START##################################################"); | 	fwrite($logFh, "################################START##################################################"); | ||||||
| 	fwrite($logFh, var_export($devices, true)); | 	fwrite($logFh, var_export($devices, true)); | ||||||
| 	fwrite($logFh, "################################END##################################################"); | 	fwrite($logFh, "################################END##################################################"); | ||||||
| 	fwrite($logFh, var_export($indexFriendlyNames, true)); |  | ||||||
| 	logger(DEBUG, _("Devices DB made"), __FILE__ . ":" . __LINE__); | 	logger(DEBUG, _("Devices DB made"), __FILE__ . ":" . __LINE__); | ||||||
| 	//print_r($devices); | 	//print_r($devices); | ||||||
| } | } | ||||||
| @@ -175,7 +174,7 @@ function iterateDevice($topic, $fn, $parentDevice, &$properties, $payloadArray, | |||||||
| 	//echo "PropertyTree ==============> " . $propertyTree . EOL; | 	//echo "PropertyTree ==============> " . $propertyTree . EOL; | ||||||
| 	foreach($payloadArray as $key => $value) | 	foreach($payloadArray as $key => $value) | ||||||
| 	{ | 	{ | ||||||
| 		$oldValue = null; | 		//$oldValue = null; | ||||||
| 		//echo "key =>"; print_r($key); echo EOL; | 		//echo "key =>"; print_r($key); echo EOL; | ||||||
| 		//echo "value =>"; var_dump($value); echo EOL; | 		//echo "value =>"; var_dump($value); echo EOL; | ||||||
| 		//echo "type : " . gettype($value) .EOL; | 		//echo "type : " . gettype($value) .EOL; | ||||||
| @@ -279,6 +278,7 @@ function changeValue(&$property, $value, &$parentDevice, $propertyTree, $key) | |||||||
| 	//$changed[$fn]["value"] = $value; | 	//$changed[$fn]["value"] = $value; | ||||||
| 	logger(INFO, sprintf(_("Logging Device property %s, %s"), $propertyTree . $key, bool2string($value)), __FILE__ . ":" . __LINE__); | 	logger(INFO, sprintf(_("Logging Device property %s, %s"), $propertyTree . $key, bool2string($value)), __FILE__ . ":" . __LINE__); | ||||||
| 	$mohaDB->logProperty($parentDevice, $key, $value, $property["value"]); | 	$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; | 	$property["value"] = $value; | ||||||
| 	if (!empty($property["functions"])) | 	if (!empty($property["functions"])) | ||||||
| 	{ | 	{ | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ function checkEvents() | |||||||
| { | { | ||||||
| 	global $logLevel, $events; | 	global $logLevel, $events; | ||||||
| 	$oldLevel = $logLevel; | 	$oldLevel = $logLevel; | ||||||
| 	$loglevel = DEBUG; | 	$logLevel = DEBUG; | ||||||
| 	$exception = false; | 	$exception = false; | ||||||
| 	foreach ($events as $key => $event) | 	foreach ($events as $key => $event) | ||||||
| 	{ | 	{ | ||||||
| @@ -104,7 +104,7 @@ function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=fal | |||||||
| { | { | ||||||
| 	global $events, $logLevel; | 	global $events, $logLevel; | ||||||
| 	$oldLevel = $logLevel; | 	$oldLevel = $logLevel; | ||||||
| 	$loglevel = DEBUG; | 	$logLevel = DEBUG; | ||||||
| 	$datetime = new dateTime(); | 	$datetime = new dateTime(); | ||||||
| 	strtolower($unit); | 	strtolower($unit); | ||||||
| 	switch($unit) | 	switch($unit) | ||||||
| @@ -156,7 +156,7 @@ function setDelay(&$deviceObject, $delay, $unit, $property, $value, $replace=fal | |||||||
| 	$events[$key]->device = & $deviceObject; | 	$events[$key]->device = & $deviceObject; | ||||||
| 	logger (DEBUG, _('Setting new delay in $events[]'), __FILE__ . ":" . __LINE__); | 	logger (DEBUG, _('Setting new delay in $events[]'), __FILE__ . ":" . __LINE__); | ||||||
| 	//print_r($events[$key]); | 	//print_r($events[$key]); | ||||||
| 	$loglevel = $oldLevel; | 	$logLevel = $oldLevel; | ||||||
| } | } | ||||||
|  |  | ||||||
| function removeEvent($deviceObject, $property , $value) | function removeEvent($deviceObject, $property , $value) | ||||||
|   | |||||||
| @@ -39,8 +39,8 @@ class rdc_chambre_eclairage extends hook | |||||||
| 	private function send($deviceObject, $state, $delayState = false, $method = MANUAL) | 	private function send($deviceObject, $state, $delayState = false, $method = MANUAL) | ||||||
| 	{ | 	{ | ||||||
| 		global $devices, $indexDevices; | 		global $devices, $indexDevices; | ||||||
| 		$msg = array("state" => $state); | 		$msg = array("state_l1" => $state); | ||||||
| 		if ($deviceObject->properties["state"]["value"] != $state) | 		if ($deviceObject->properties["state_l1"]["value"] != $state) | ||||||
| 		{ | 		{ | ||||||
| 			logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__); | 			logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__); | ||||||
| 			$deviceObject->payload = $msg; | 			$deviceObject->payload = $msg; | ||||||
|   | |||||||
| @@ -26,32 +26,34 @@ class rdc_salon_eclairage extends hook | |||||||
| 		$lux = $indexDevices[RDC_SALON_LUMINOSITE]; | 		$lux = $indexDevices[RDC_SALON_LUMINOSITE]; | ||||||
| 		$mvmt = $indexDevices[RDC_SALON_MVMT]; | 		$mvmt = $indexDevices[RDC_SALON_MVMT]; | ||||||
| 		$mvmt2 = $indexDevices[RDC_SALON_MVMT2]; | 		$mvmt2 = $indexDevices[RDC_SALON_MVMT2]; | ||||||
|  | 		logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__); | ||||||
|  |  | ||||||
| 		switch($param) | 		switch($param) | ||||||
| 		{ | 		{ | ||||||
| 			case "occupancy": | 			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")); | 				//print_r(getValue(RDC_SALON_LUMINOSITE, "illuminance_lux")); | ||||||
| 				if ($value == ON and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min) | 				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); | 					$this->send($deviceTarget, "ON", null, AUTO); | ||||||
| 					removeEvent($deviceTarget, "state", "OFF"); | 					removeEvent($deviceTarget, "state", "OFF"); | ||||||
| 				}elseif ($value == 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)) | 					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); | 						setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true); | ||||||
| 						//$this->send($deviceTarget, "ON", "OFF", AUTO); | 						//$this->send($deviceTarget, "ON", "OFF", AUTO); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 			case "contact": | 			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") | 				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) | 					if (getValue(RDC_SALON_MVMT, "occupancy") == ON or getValue(RDC_SALON_MVMT2, "occupancy") == ON) | ||||||
| 					{ | 					{ | ||||||
| 						$this->send($deviceTarget, "ON", null, AUTO); | 						$this->send($deviceTarget, "ON", null, AUTO); | ||||||
| @@ -62,10 +64,10 @@ class rdc_salon_eclairage extends hook | |||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 			case "illuminance_lux": | 			case "illuminance_lux": | ||||||
| 				logger(DEBUG, _("CASE : Illuminance"), __FILE__ . ":" . __LINE__); | 				logger(INFO, _("CASE : Illuminance"), __FILE__ . ":" . __LINE__); | ||||||
| 				if ($value >= $this->luminance_max) | 				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); | 					//$this->send($deviceTarget, "OFF", null, AUTO); | ||||||
| 					//removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF"); | 					//removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF"); | ||||||
| 					if (searchEvent($deviceTarget, "state", "OFF") === false) | 					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)) | 				}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); | 					$this->send($deviceTarget, "ON", null, AUTO); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
|   | |||||||
| @@ -112,7 +112,7 @@ function webBrowse($socket, $argList) | |||||||
|  |  | ||||||
| function iterateProperty($property, $value, &$response, $tab="") | function iterateProperty($property, $value, &$response, $tab="") | ||||||
| { | { | ||||||
| 	$tab .= "   "; | 	$tab .= "     "; | ||||||
| 	if (is_array($value) or is_object($value)) | 	if (is_array($value) or is_object($value)) | ||||||
| 	{ | 	{ | ||||||
| 		logger(DEBUG, _("is object or array"), __FILE__ . ":" . __LINE__ ); | 		logger(DEBUG, _("is object or array"), __FILE__ . ":" . __LINE__ ); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user