diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-05-11 07:27:12 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2021-05-11 07:27:12 +0200 |
commit | 2a1ca8ac1ccd0a6886a9a3b82c8b5d4421c5905e (patch) | |
tree | 08cebc5650884d86b5b0a9d4470c45a53f23b3f1 /scd4x | |
parent | a27b1376f9e89577e765f4e5beefe43ae968423e (diff) | |
download | hue-2a1ca8ac1ccd0a6886a9a3b82c8b5d4421c5905e.tar.gz |
use serial
Diffstat (limited to 'scd4x')
-rwxr-xr-x | scd4x | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -7,7 +7,6 @@ use JSON; use Net::MQTT::Simple; my $file = shift; -my $name = shift; my $host = shift; my $json = JSON->new->allow_nonref; @@ -32,10 +31,10 @@ my $values; my $pvalues; for (;;) { $values = read_json_file($file); - for my $key (sort keys %{$values}) { - next if $key eq "timestamp"; + my $serial = $values->{'serial'} + for my $key ('co2', 'temperature', 'humidity') { next if defined($pvalues->{$key}) and $pvalues->{$key} eq $values->{$key}; - my $topic = "sensors/" . $key . "/" . $name; + my $topic = "sensors/" . $key . "/scd4x/" . $serial; if (defined($mqtt)) { $mqtt->retain( $topic => $values->{$key} ); } else { |