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