summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/stats/telegraf/bamstats.nix
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2017-12-30 11:36:15 +0100
committerlassulus <lassulus@lassul.us>2017-12-30 11:36:15 +0100
commitc1ff2ddf713242f34a56861c34d815ae6985798b (patch)
treea12734de3e7f99b58e87560317f383ed6bdd9c41 /makefu/2configs/stats/telegraf/bamstats.nix
parentdd817f9e26ee2aeae839dddc73b869d218a337cb (diff)
parent9d4436644115c2cc5c130d9c210c201bb506c789 (diff)
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs/stats/telegraf/bamstats.nix')
-rw-r--r--makefu/2configs/stats/telegraf/bamstats.nix35
1 files changed, 35 insertions, 0 deletions
diff --git a/makefu/2configs/stats/telegraf/bamstats.nix b/makefu/2configs/stats/telegraf/bamstats.nix
new file mode 100644
index 000000000..ae5301204
--- /dev/null
+++ b/makefu/2configs/stats/telegraf/bamstats.nix
@@ -0,0 +1,35 @@
+{ 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.telegraf.extraConfig.inputs.mqtt_consumer =
+ (dht22 "easy1")
+ ++ (dht22 "easy2")
+ ++ (dht11 "easy3")
+ ++ (ds18 "easy3");
+}