blob: a9f49651fa280d5f4d2be75a9830e3edeaf4a2b3 (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
{
config,
pkgs,
...
}: {
system.stateVersion = "24.05";
turris.board = "mox";
deploy = {
enable = true;
ssh.host = "mox.spt";
configurationLimit = 8;
};
cynerd = {
monitoring.drives = false;
switch = {
enable = true;
lanAddress = "${config.cynerd.hosts.spt.mox}/24";
lanGateway = config.cynerd.hosts.spt.omnia;
};
wifiAP.spt = {
enable = true;
qca988x = {
interface = "wlp1s0";
bssids = config.secrets.wifiMacs.spt-mox.qca988x;
channel = 7;
};
};
};
services = {
journald.extraConfig = ''
SystemMaxUse=512M
'';
btrfs.autoScrub = {
enable = true;
fileSystems = ["/"];
};
};
networking = {
useNetworkd = true;
useDHCP = false;
};
systemd.network.networks = {
"lan-brlan" = {
matchConfig.Name = "lan* end0";
networkConfig.Bridge = "brlan";
bridgeVLANs = [
{
EgressUntagged = 1;
PVID = 1;
}
{VLAN = 2;}
];
};
};
##############################################################################
networking.firewall.allowedTCPPorts = [
1883 # Mosquitto
];
services = {
mosquitto = {
enable = true;
listeners = [
{
users = {
cynerd = {
acl = ["readwrite #"];
passwordFile = "/run/secrets/mosquitto.cynerd.pass";
};
telegraf = {
acl = ["read bigclown/node/#"];
passwordFile = "/run/secrets/mosquitto.telegraf.pass";
};
bigclown = {
acl = ["readwrite bigclown/#"];
passwordFile = "/run/secrets/mosquitto.bigclown.pass";
};
};
}
];
};
telegraf.extraConfig = {
outputs.influxdb_v2 = [
{
urls = ["http://cynerd.cz:8086"];
token = "$INFLUX_TOKEN";
organization = "personal";
bucket = "bigclown";
tagpass.source = ["bigclown"];
}
];
inputs.mqtt_consumer = let
consumer = data_type: topics: {
tags = {source = "bigclown";};
servers = ["tcp://localhost:1883"];
inherit topics;
username = "telegraf";
password = "$MQTT_PASSWORD";
data_format = "value";
inherit data_type;
topic_parsing = [
{
topic = "bigclown/node/+/+/+/+";
measurement = "_/_/_/_/_/measurement";
tags = "_/_/device/field/_/_";
}
];
};
in [
(consumer "float" [
"bigclown/node/+/battery/+/voltage"
"bigclown/node/+/thermometer/+/temperature"
"bigclown/node/+/hygrometer/+/relative-humidity"
"bigclown/node/+/lux-meter/+/illuminance"
"bigclown/node/+/barometer/+/pressure"
"bigclown/node/+/pir/+/event-count"
"bigclown/node/+/push-button/+/event-count"
])
(consumer "boolean" [
"bigclown/node/+/flood-detector/+/alarm"
])
];
processors.pivot = [
{
tag_key = "field";
value_key = "value";
tagpass.source = ["bigclown"];
}
];
};
bcg = {
enable = true;
device = "/dev/ttyUSB0";
baseTopicPrefix = "bigclown/";
environmentFiles = ["/run/secrets/bigclown.env"];
mqtt = {
username = "bigclown";
password = "\${MQTT_PASSWORD}";
};
};
};
systemd.services = {
telegraf.wants = ["mosquitto.service"];
bigclown-leds = {
description = "Bigclown LEDs control";
wantedBy = ["multi-user.target"];
wants = ["mosquitto.service"];
serviceConfig.ExecStart = "${pkgs.bigclown-leds}/bin/bigclown-leds /run/secrets/bigclown-leds.ini";
};
};
}
|