added notify command to webserver
This commit is contained in:
@ -73,6 +73,53 @@ class event
|
||||
public $exceptionInterval; // array of object ranges
|
||||
}
|
||||
|
||||
class watch
|
||||
{
|
||||
public $topic;
|
||||
public $property;
|
||||
public $device;
|
||||
public $function;
|
||||
private $conditions = array(
|
||||
"<", ">", "==", ">=", "<="
|
||||
);
|
||||
|
||||
public function __construct($topic, $fn, $property, $condition, $value)
|
||||
{
|
||||
logger(DEBUG, _("New Notify object"), __FILE__ . ":" . __LINE__);
|
||||
if (($this->device = getDevice($topic, $fn)) === false)
|
||||
{
|
||||
$this->topic = $topic;
|
||||
if (array_key_exist($property, $this->device))
|
||||
{
|
||||
$this->property = $property;
|
||||
if ( !is_numeric($value))
|
||||
{
|
||||
logger(ERROR, _("Value is not numeric"), __FILE__ . ":" . __LINE__ );
|
||||
return false;
|
||||
}
|
||||
if (array_search($condition, $conditions))
|
||||
{
|
||||
$this->function = '$arg ' . $condition . " " . $value;
|
||||
logger(DEBUG, _("Test function is ") . $this->function);
|
||||
}else
|
||||
{
|
||||
logger(ERROR, _("Condition is not one of the permitted once"), __FILE__ . ":" . __LINE__ );
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
logger(ERROR, _("Property do not exists"), __FILE__ . ":" . __LINE__ );
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
logger(ERROR, _("Device do not exists"), __FILE__ . ":" . __LINE__ );
|
||||
return false;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
class interval
|
||||
{
|
||||
public $startDate;
|
||||
|
Reference in New Issue
Block a user