X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=parse.pl;h=9c6e5bf695c93f26422eb112c5911977a159f426;hb=6c5241bab8a965adf649d6641ca318d659d17044;hp=6b9b81a8319df6d10088ca8166885e168f149e52;hpb=ef514be0a3ea944ceb7d65d95806315aa408818d;p=vaillant-thermostat diff --git a/parse.pl b/parse.pl index 6b9b81a..9c6e5bf 100755 --- a/parse.pl +++ b/parse.pl @@ -2,24 +2,38 @@ use warnings; use strict; +my $curl; +my $influx = $ENV{INFLUX}; # || 'http://127.0.0.1:8086/write?db=boiler'; + +my $temp = ''; + while(<>) { chomp; - if ( m/^([0-9\.]+) .+aa fc 39 aa (.+) \|\s+(\d+\.\d+)/ ) { + if ( s/\s+\|\s+(\d+\.\d\d).+$// ) { + $temp = $1; + } +#$temp = ( $temp - 20 ) * 500 + 500; + if ( m/^([0-9\.]+) .+aa fc 39 aa (.+)/ ) { + my $t = $1; #warn "# $1 $2\n"; - my $temp = $3; my @l = split(/\s+/,$2); my @d = ( - $1, + $t, hex( $l[0] . $l[1] ), hex( $l[3] . $l[4] ), hex( $l[6] ), hex( $l[12] ), - hex( $l[14] ) * 300, - hex( $l[15] ) * 400, + hex( $l[14] ), # * 300, + hex( $l[15] ), # * 400, hex( $l[18] ), $temp ); - print join(',', @d),$/; + if ( $influx ) { + open($curl, '|-', qq( tee /dev/shm/parse.curl | curl -XPOST $influx --data-binary \@- )) unless $curl; + print $curl "thermostat ",join(',', map { chr( ord('a') + $_ ) . '=' . $d[$_] . 'i' } 1 .. $#d ), ($temp ? ",temp=$temp" : ""), " ", int($t * 1_000_000_000), "\n"; + } else { + print join(',', @d,$temp),$/; + } } else { warn "# $_\n"; }