--- /dev/null
+#!/usr/bin/perl
+use common::sense;
+use Device::SerialPort;
+use Data::Dumper;
+use Net::MQTT::Simple;
+
+my $port = Device::SerialPort->new('/dev/ttyUSB0', 0);
+$port->baudrate(115200);
+$port->parity('none');
+$port->databits(8);
+$port->stopbits(1);
+$port->handshake('none');
+$port->stty_icanon(1);
+$port->read_char_time(1);
+$port->purge_all;
+
+my $mqtt = Net::MQTT::Simple->new('micac.vojtech.kobylisy.czf') or die "Cannot connect to MQTT";
+
+my @desc = qw(outside-exhaust inside-exhaust outside-intake chilled inside-intake bypass fan-pwm);
+
+for (;;) {
+ my $line = $port->read(255);
+ chomp $line;
+ $line =~ s{\r}{}g;
+ next if $line eq "";
+ my @fields = split /\s+/, $line;
+ unless (@fields == @desc + 1 && $fields[0] eq '#') {
+ print STDERR "Malformed line: $line\n";
+ next;
+ }
+ # print join("|", @fields), "\n";
+
+ my $now = time;
+ for my $i (0..$#desc) {
+ $mqtt->retain('burrow/air/' . $desc[$i], join(" ", $fields[$i+1], $now));
+ print $desc[$i], '=', $fields[$i+1], " ";
+ }
+ print "\n";
+}