X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=serial.pl;h=c08a73e1397514479fd3ef093abe0f6e74ab33a0;hb=720c72fa7b481a1b1e2145491274f897749bb19e;hp=cfceb37bb160586d0d0314d0b13b0ee52a8d47e3;hpb=db5e8c623278aa03ac9f57f2da58a9e218f1be13;p=vaillant-thermostat diff --git a/serial.pl b/serial.pl index cfceb37..c08a73e 100755 --- a/serial.pl +++ b/serial.pl @@ -7,7 +7,7 @@ use Time::HiRes qw(time); my $read_len = 255; -my $path = shift @ARGV || '/dev/serial/by-path/platform-20980000.usb-usb-0:1.3.1:1.0-port0'; +my $path = shift @ARGV || '/dev/serial/by-path/platform-20980000.usb-usb-0:1.2:1.0-port0'; $|=1; @@ -32,7 +32,7 @@ sub _mqtt_pub { my ( $t, $m ) = @_; my $cmd = "mosquitto_pub -h rpi2 -t '$t' -m '$m'"; #warn "# _mqtt_pub [$t] = [$m]\n"; - warn "## $cmd"; + #warn "## $cmd"; system $cmd; } @@ -45,7 +45,7 @@ while (1) { my $hex = unpack('H*',$string); $hex =~ s/(..)/$1 /g; - my $temp = `curl localhost:3000/temp.txt`; + my $temp = `curl --silent localhost:3000/temp.txt`; $temp =~ s/\s+/ /gs; $temp =~ s/^\s+//; @@ -68,8 +68,9 @@ 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 ); + my @v = split(/\s+/, $temp, 4); + my @n = qw( DS18B20/temperature DHT22/temperature DHT22/humidity DHT22/errors ); + @n = qw( DS18B20/temperature DHT22/temperature DHT22/humidity DHT22/errors ) if $#v == 1; # no DS18B20 foreach (@v) { _mqtt_pub "stat/boiler/" . shift(@n) => $_; }