From f61c21fbadb78eb8724e57680576acb371bd78e0 Mon Sep 17 00:00:00 2001 From: Dirk Heilig Date: Mon, 9 Sep 2024 19:22:32 +0200 Subject: [PATCH] fix --- mqtt2prom/run | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mqtt2prom/run b/mqtt2prom/run index 5562c13..034e70b 100755 --- a/mqtt2prom/run +++ b/mqtt2prom/run @@ -80,6 +80,9 @@ $mqtt->onMessage(function ($message) use ( $payload = (array) json_decode($message->payload, true); $payload["timestamp"] = time(); + if (!isset($payload["valid_seconds"])) { + $payload["valid_seconds"] = 60; + } $data[] = $payload; $news = true; }); @@ -174,9 +177,6 @@ function precheck(Message $message): bool } } - if (!isset($payload["valid_seconds"])) { - $payload["valid_seconds"] = 60; - } if (!is_numeric($payload["valid_seconds"])) { error("valid_seconds must be a number"); return false;