fix: remove extra quotes

master
Dirk Heilig 2023-01-19 15:01:30 +01:00
parent 5a237e8c81
commit 1f91f2c7f3
1 changed files with 2 additions and 1 deletions

View File

@ -35,10 +35,11 @@ $c->onMessage(function (\Mosquitto\Message $message) use (&$data, $conf) {
" unknown\n"; " unknown\n";
die(1); die(1);
} }
var_dump($data);
$data[$message->topic]["changed"] = time(); $data[$message->topic]["changed"] = time();
$out = file_get_contents(__DIR__ . "/template.json"); $out = file_get_contents(__DIR__ . "/template.json");
$out = preg_replace_callback( $out = preg_replace_callback(
"/{{(?<name>[^#}]+?)(#(?<modifier>[^}]+))?}}/", "/\"{{(?<name>[^#}]+?)(#(?<modifier>[^}]+))?}}\"/",
function ($m) use ($data, $conf) { function ($m) use ($data, $conf) {
$value = $data[$conf["variables"][$m["name"]]["topic"]]["value"]; $value = $data[$conf["variables"][$m["name"]]["topic"]]["value"];
$modifier = isset($m["modifier"]) ? $m["modifier"] : "noop"; $modifier = isset($m["modifier"]) ? $m["modifier"] : "noop";