1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
povSelf,
pkgs,
lib,
config,
hostConfig,
...
}:
let
inherit (lib) types;
cfg = lib.getAttrFromPath povSelf config;
in
{
option = {
type = types.bool;
default = false;
};
config = lib.mkIf cfg {
sops.secrets."environments/telegraf" = {
owner = "telegraf";
};
services.telegraf = {
enable = true;
environmentFiles = [ config.sops.secrets."environments/telegraf".path ];
extraConfig = {
inputs = {
mqtt_consumer = {
servers = [ "tcp://[::1]:1883" ];
topics = [
"zigbee2mqtt/tuya_sensor_fridge"
"zigbee2mqtt/tuya_sensor_bathroom"
"zigbee2mqtt/tuya_sensor_sleepingroom"
"zigbee2mqtt/tuya_sensor_l2"
];
data_format = "json";
fielddrop = [
"newBatt"
"weakBatt"
];
};
};
outputs = {
influxdb_v2 = [
{
urls = [ "http://${toString config.services.influxdb2.settings.http-bind-address}/" ];
organization = "smarthome";
bucket = "mqttData";
token = "\${INFLUX_TOKEN_MQTTDATA}";
}
];
};
};
};
};
}