diff options
author | lassulus <lass@blue.r> | 2018-09-18 15:47:03 +0200 |
---|---|---|
committer | lassulus <lass@blue.r> | 2018-09-18 15:47:03 +0200 |
commit | 245994cc7ace5a323c476ccc50fd4026b9353dc4 (patch) | |
tree | cf4a3d85c768bd1ca18913d17c67e07bcab95db7 /makefu/2configs/stats/telegraf/hamstats.nix | |
parent | 1466d3e86abc4d85af6efe5a964df788cf0e36cc (diff) | |
parent | 8a756c7333e0e7c4a0433d68775f8d7c1a53b8b0 (diff) |
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs/stats/telegraf/hamstats.nix')
-rw-r--r-- | makefu/2configs/stats/telegraf/hamstats.nix | 28 |
1 files changed, 28 insertions, 0 deletions
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 <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"); +} |