continued watch device property
This commit is contained in:
		| @@ -77,11 +77,13 @@ class watch | |||||||
| { | { | ||||||
| 	public $topic; | 	public $topic; | ||||||
| 	public $property; | 	public $property; | ||||||
|  | 	public $PropertyValue; | ||||||
| 	public $device; | 	public $device; | ||||||
| 	public $function; | 	public $function; | ||||||
| 	private $conditions = array( | 	private $conditions = array( | ||||||
| 		"<", ">", "==", ">=", "<=" | 		"<", ">", "==", ">=", "<=" | ||||||
| 		); | 		); | ||||||
|  | 	public $condition; | ||||||
|  |  | ||||||
| 	public function __construct($topic, $fn, $property, $condition, $value) | 	public function __construct($topic, $fn, $property, $condition, $value) | ||||||
| 	{ | 	{ | ||||||
| @@ -92,20 +94,21 @@ class watch | |||||||
| 			if (array_key_exist($property, $this->device)) | 			if (array_key_exist($property, $this->device)) | ||||||
| 			{ | 			{ | ||||||
| 				$this->property = $property; | 				$this->property = $property; | ||||||
| 				if ( !is_numeric($value)) | 				if (!is_numeric($value)) | ||||||
| 				{ | 				{ | ||||||
| 					logger(ERROR, _("Value is not numeric"), __FILE__ . ":" . __LINE__ ); | 					logger(ERROR, _("Value is not numeric"), __FILE__ . ":" . __LINE__ ); | ||||||
| 					return false; | 					return false; | ||||||
| 				} | 				} | ||||||
| 				if (array_search($condition, $conditions)) | 				if (array_search($condition, $conditions)) | ||||||
| 				{ | 				{ | ||||||
| 					$this->function = '$arg ' . $condition . " " . $value; | 					$this->function = '$value ' . $condition . " " . $value; | ||||||
| 					logger(DEBUG, _("Test function is ") . $this->function); | 					logger(DEBUG, _("Test function is ") . $this->function); | ||||||
| 				}else | 				}else | ||||||
| 				{ | 				{ | ||||||
| 					logger(ERROR, _("Condition is not one of the permitted once"), __FILE__ . ":" . __LINE__ ); | 					logger(ERROR, _("Condition is not one of the permitted"), __FILE__ . ":" . __LINE__ ); | ||||||
| 					return false; | 					return false; | ||||||
| 				} | 				} | ||||||
|  | 				$this->device[$ieeeAddress]->$property["functions"][] = array($this,"notifyCallback"); | ||||||
| 			}else | 			}else | ||||||
| 			{ | 			{ | ||||||
| 				logger(ERROR, _("Property do not exists"), __FILE__ . ":" . __LINE__ ); | 				logger(ERROR, _("Property do not exists"), __FILE__ . ":" . __LINE__ ); | ||||||
| @@ -118,6 +121,17 @@ class watch | |||||||
| 		} | 		} | ||||||
| 		return $this; | 		return $this; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	public function notifyCallback(&$device, $property, $value) | ||||||
|  | 	{ | ||||||
|  | 		if (eval($this->function)) | ||||||
|  | 		{ | ||||||
|  | 			$msg = sprintf(_("Device '%s' have property '%s' value %s %s %s"), $device->friendlyName, $property, $value, $this->condition, $this->PropertyValue ); | ||||||
|  | 			notify($msg); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| class interval | class interval | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user