From 375b01004e645acd645e5daac6361705ae504133 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 18 Sep 2018 12:46:39 +0200 Subject: [PATCH] ma telegraf/hamstats: init --- makefu/2configs/stats/telegraf/hamstats.nix | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 makefu/2configs/stats/telegraf/hamstats.nix diff --git a/makefu/2configs/stats/telegraf/hamstats.nix b/makefu/2configs/stats/telegraf/hamstats.nix new file mode 100644 index 000000000..88c1b6d5d --- /dev/null +++ b/makefu/2configs/stats/telegraf/hamstats.nix @@ -0,0 +1,28 @@ +{ pkgs, ...}: + +let + genTopic = name: topic: tags: { + servers = [ "tcp://localhost:1883" ]; + username = "stats"; + password = builtins.readFile ; + 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"); +}