aboutsummaryrefslogtreecommitdiffstats
path: root/scd4x
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2021-05-11 07:27:12 +0200
committerGerd Hoffmann <kraxel@redhat.com>2021-05-11 07:27:12 +0200
commit2a1ca8ac1ccd0a6886a9a3b82c8b5d4421c5905e (patch)
tree08cebc5650884d86b5b0a9d4470c45a53f23b3f1 /scd4x
parenta27b1376f9e89577e765f4e5beefe43ae968423e (diff)
downloadhue-2a1ca8ac1ccd0a6886a9a3b82c8b5d4421c5905e.tar.gz
use serial
Diffstat (limited to 'scd4x')
-rwxr-xr-xscd4x7
1 files changed, 3 insertions, 4 deletions
diff --git a/scd4x b/scd4x
index 6978a9f..5bef804 100755
--- a/scd4x
+++ b/scd4x
@@ -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 {