continued watch device property
This commit is contained in:
parent
4b226c1d0a
commit
85db4e3ff4
@ -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)
|
||||
{
|
||||
@ -99,13 +101,14 @@ class watch
|
||||
}
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user