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

@@ -72,12 +72,7 @@ function askWebServer($read)
{
if(!empty($topic))
{
$var = $var[$topic];
$path = explode("/", $argList["fn"]);
foreach($path as $tmp)
{
$var = $var[$tmp];
}
$var = getDevice($topic, $argList["fn"]);
}else
{
$str = _("topic is not defining: add &topic=\nThese topics are availables: ");
@@ -103,6 +98,15 @@ function askWebServer($read)
}
fwrite($spawn, $response);
break;
case "notify":
if (!array_key_exists("topic", $argList) or !array_key_exists("fn", $argList) or !array_key_exists("property", $argList) or !array_key_exists("condition", $argList) or !array_key_exists("value", $argList))
{
fwrite($spawn, _("Error: With 'notify' command, you need 4 parameters: topic, fn, property, condition, value"));
}else
{
$monitored[] = new watch($argList["topic"], $argList["fn"], $argList["property"], $argList["condition"], $argList["value"]);
}
break;
default:
logger(DEBUG, _("unknown command"), __FILE__ . ":" . __LINE__);
fwrite($spawn, _("unknown command"));