aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-10-22 14:37:30 +0200
committerGerd Hoffmann <kraxel@redhat.com>2017-10-22 14:37:30 +0200
commit1638e7ebd7db0fbc8d5281b0f6ae76aa49957047 (patch)
treecff442d02366d923cb2122dd1a49809abd771179
parent528e9e1692794c6f9b393302d36dea7ae83d35df (diff)
downloadhue-1638e7ebd7db0fbc8d5281b0f6ae76aa49957047.tar.gz
fix float format
-rwxr-xr-xelv-weather12
1 files changed, 9 insertions, 3 deletions
diff --git a/elv-weather b/elv-weather
index b993a4c..4413b9c 100755
--- a/elv-weather
+++ b/elv-weather
@@ -46,7 +46,7 @@ my @paths = (
my $host = shift;
my $base = shift;
my $port = shift;
-my ($elv,$mqtt,$line,@data,@prev,$updates);
+my ($elv,$mqtt,$line,@data,@prev,$updates,$topic,$value);
# handle args
my @devs = glob("/dev/serial/by-id/usb-*ELV_USB-WDE1*");
@@ -111,11 +111,17 @@ while (1) {
next;
}
- # update mqtt
$updates = 0;
for my $i (0 .. (scalar(@paths) - 1)) {
next if $paths[$i] eq "unused";
- $mqtt->retain( "$base/$paths[$i]" => "$data[$i]");
+
+ # update mqtt
+ $topic = $base . "/" . $paths[$i];
+ $value = $data[$i];
+ $value =~ s/,/./; # de -> us float format
+ $mqtt->retain( $topic => $value );
+
+ # log changes
if ((!defined($prev[$i]) || $data[$i] ne $prev[$i]) && $verbose) {
$updates++;
if ($updates == 1) {