ma telegraf/hamstats: init

This commit is contained in:
makefu 2018-09-18 12:46:39 +02:00
parent 0675584001
commit 375b01004e
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -0,0 +1,28 @@
{ pkgs, ...}:
let
genTopic = name: topic: tags: {
servers = [ "tcp://localhost:1883" ];
username = "stats";
password = builtins.readFile <secrets/mqtt/stats>;
qos = 0;
connection_timeout = "30s";
topics = [ topic ];
tags = tags;
persistent_session = false;
name_override = name;
data_format = "json";
# json_query = tags.sensor; #TODO?
};
hamStat = host:
sensor:
(genTopic sensor
"/ham/${host}/${sensor}/tele/SENSOR"
{"host" = host;
"scope" = "ham";
"sensor" = sensor;
} );
bme = host: [(hamStat host "BME280")];
in {
services.telegraf.extraConfig.inputs.mqtt_consumer = (bme "schlafzimmer");
}