aboutsummaryrefslogtreecommitdiff
path: root/nixos/configurations/spt-mox.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/configurations/spt-mox.nix')
-rw-r--r--nixos/configurations/spt-mox.nix138
1 files changed, 130 insertions, 8 deletions
diff --git a/nixos/configurations/spt-mox.nix b/nixos/configurations/spt-mox.nix
index 989df29..8af976c 100644
--- a/nixos/configurations/spt-mox.nix
+++ b/nixos/configurations/spt-mox.nix
@@ -1,12 +1,17 @@
-{config, ...}: {
+{
+ config,
+ pkgs,
+ ...
+}: {
+ system.stateVersion = "24.05";
turris.board = "mox";
deploy = {
enable = true;
ssh.host = "mox.spt";
+ configurationLimit = 8;
};
cynerd = {
- home-assistant = true;
monitoring.drives = false;
switch = {
enable = true;
@@ -23,13 +28,15 @@
};
};
- services.journald.extraConfig = ''
- SystemMaxUse=512M
- '';
+ services = {
+ journald.extraConfig = ''
+ SystemMaxUse=512M
+ '';
- services.btrfs.autoScrub = {
- enable = true;
- fileSystems = ["/"];
+ btrfs.autoScrub = {
+ enable = true;
+ fileSystems = ["/"];
+ };
};
networking = {
@@ -49,4 +56,119 @@
];
};
};
+
+ ##############################################################################
+ 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";
+ };
+ homeassistant = {
+ acl = [
+ "readwrite homeassistant/#"
+ "readwrite bigclown/#"
+ "readwrite zigbee2mqtt/#"
+ ];
+ passwordFile = "/run/secrets/mosquitto.homeassistant.pass";
+ };
+ bigclown = {
+ acl = ["readwrite bigclown/#"];
+ passwordFile = "/run/secrets/mosquitto.bigclown.pass";
+ };
+ zigbee2mqtt = {
+ acl = [
+ "readwrite homeassistant/#"
+ "readwrite zigbee2mqtt/#"
+ ];
+ passwordFile = "/run/secrets/mosquitto.zigbee2mqtt.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";
+ };
+ };
}