diff --git a/class/main.php b/class/main.php index 14ece1c..6274980 100644 --- a/class/main.php +++ b/class/main.php @@ -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 diff --git a/watch.php b/watch.php deleted file mode 100644 index 395a8b2..0000000 --- a/watch.php +++ /dev/null @@ -1,11 +0,0 @@ -