1
0

added notify command to webserver

This commit is contained in:
2022-01-30 00:21:50 +01:00
parent 719a45fa4e
commit 4b226c1d0a
7 changed files with 97 additions and 8 deletions

View File

@ -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;