From db5e8c623278aa03ac9f57f2da58a9e218f1be13 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 20 Mar 2017 18:21:57 +0100 Subject: [PATCH] report temperature and humidity to mqtt --- serial.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serial.pl b/serial.pl index a45c9ac..cfceb37 100755 --- a/serial.pl +++ b/serial.pl @@ -47,6 +47,7 @@ while (1) { my $temp = `curl localhost:3000/temp.txt`; $temp =~ s/\s+/ /gs; + $temp =~ s/^\s+//; #printf "%s %2d %s\n", time(), $len, $hex; printf "%8.4f %6.2f %2d %s | %s\n", $ts, $ts - $t, $len, $hex, $temp; @@ -67,6 +68,12 @@ while (1) { _mqtt_pub "stat/boiler/" . chr(ord('a') + $_) => $d[$_] foreach 0 .. $#d; } + my @v = split(/\s+/, $temp, 3); + my @n = qw( DS18B20/temperature DHT22/temperature DHT22/humidity ); + foreach (@v) { + _mqtt_pub "stat/boiler/" . shift(@n) => $_; + } + } } -- 2.20.1