stats: re-enable airsensor push to mqtt

This commit is contained in:
makefu 2024-07-03 17:53:54 +02:00
parent e2a7457c2c
commit ebee284387
No known key found for this signature in database
GPG key ID: 36F7711F3FC0F225
3 changed files with 9 additions and 40 deletions
2configs/stats/telegraf
machines/wbob

View file

@ -1,31 +1,5 @@
{ pkgs, ...}:
let
genTopic = name: topic: tags: {
servers = [ "tcp://localhost:1883" ];
qos = 0;
connection_timeout = "30s";
topics = [ topic ];
tags = tags;
persistent_session = false;
name_override = name;
data_format = "value";
data_type = "float";
};
bamStat = stat: # Temperature or Humidity
host: # easy{1-4}
sensor: # dht11, dht22, ds18
(genTopic stat
"/bam/${host}/${sensor}/${stat}"
{"host" = host;
"scope" = "bam";
"sensor" = sensor;
} );
dht22 = host: [(bamStat "Temperature" host "dht22")
(bamStat "Humidity" host "dht22")];
dht11 = host: [(bamStat "Temperature" host "dht11")
(bamStat "Humidity" host "dht11")];
ds18 = host: [(bamStat "Temperature" host "ds18")];
in {
{
services.udev.extraRules = ''
SUBSYSTEMS=="usb", ATTRS{product}=="iAQ Stick", GROUP="input"
'';
@ -41,9 +15,4 @@ in {
tags.unit="VOC";
}
];
services.telegraf.extraConfig.inputs.mqtt_consumer =
(dht22 "easy1")
++ (dht22 "easy2")
++ (dht11 "easy3")
++ (ds18 "easy3");
}

View file

@ -17,13 +17,13 @@ in {
# data_format = "influx";
#}];
#mqtt = [{
# servers = [ mqtt_server ];
# topic_prefix = "/telegraf";
# data_format = "json";
# qos = 0;
# batch = false;
#}];
mqtt = [{
servers = [ mqtt_server ];
topic = "/telegraf/wbob/airquality";
data_format = "json";
qos = 0;
batch = false;
}];
};
};
};

View file

@ -51,7 +51,7 @@ in {
# ../../2configs/stats/collectd-client.nix
../../2configs/stats/telegraf
../../2configs/stats/telegraf/airsensor.nix
../../2configs/stats/telegraf/europastats.nix
# ../../2configs/stats/telegraf/europastats.nix
# ../../2configs/stats/external/aralast.nix
# ../../2configs/stats/arafetch.nix
# ../../2configs/hw/mceusb.nix