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