aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2025-01-24 15:01:30 +0100
committerKarel Kočí <cynerd@email.cz>2025-01-24 15:01:30 +0100
commit2f532dc573e35128ea82315289a0714579c9142a (patch)
tree124ee6bcfce253ca04633af2ebe659016ee06500 /nixos/modules
parent55be775b8478c78e3923fba46b6a49d86d81dfb2 (diff)
downloadnixos-personal-master.tar.gz
nixos-personal-master.tar.bz2
nixos-personal-master.zip
nixos: refactor the home automationHEADmaster
This moves zigbee to spt-omnia.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/home-assistant.nix164
-rw-r--r--nixos/modules/home-assistant/light.nix13
-rw-r--r--nixos/modules/home-assistant/sensors.nix19
3 files changed, 0 insertions, 196 deletions
diff --git a/nixos/modules/home-assistant.nix b/nixos/modules/home-assistant.nix
deleted file mode 100644
index ab16e8a..0000000
--- a/nixos/modules/home-assistant.nix
+++ /dev/null
@@ -1,164 +0,0 @@
-{
- config,
- lib,
- pkgs,
- ...
-}: let
- inherit (lib) mkIf mkEnableOption;
-in {
- options = {
- cynerd.home-assistant = mkEnableOption "Enable Home Assistant and Bigclown";
- };
-
- config = mkIf config.cynerd.home-assistant {
- 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";
- };
- };
- }
- ];
- };
- networking.firewall.allowedTCPPorts = [
- 1883 # Mosquitto
- ];
-
- services.bcg = {
- enable = true;
- device = "/dev/ttyUSB0";
- baseTopicPrefix = "bigclown/";
- environmentFiles = ["/run/secrets/bigclown.env"];
- mqtt = {
- username = "bigclown";
- password = "\${MQTT_PASSWORD}";
- };
- };
-
- systemd.services.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";
- };
-
- services.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"];
- }
- ];
- };
- systemd.services.telegraf.wants = ["mosquitto.service"];
-
- #nixpkgs.config.permittedInsecurePackages = ["openssl-1.1.1w"]; # TODO
- services.home-assistant = {
- enable = false;
- openFirewall = true;
- configDir = "/var/lib/hass";
- config = {
- homeassistant = {
- name = "SPT";
- latitude = "!secret latitude";
- longitude = "!secret longitude";
- elevation = "!secret elevation";
- time_zone = "Europe/Prague";
- country = "CZ";
- };
- http.server_port = 8808;
- mqtt = {
- sensor = import ./home-assistant/sensors.nix;
- light = import ./home-assistant/light.nix;
- };
- default_config = {};
- automation = "!include automations.yaml";
- };
- extraComponents = ["met"];
- package = pkgs.home-assistant.override {
- extraPackages = pkgs:
- with pkgs; [
- securetar
- pyipp
- ];
- packageOverrides = _: super: {
- scapy = super.scapy.override {
- withPlottingSupport = false;
- };
- s3transfer = super.s3transfer.overridePythonAttrs {
- dontUsePytestCheck = true;
- dontUseSetuptoolsCheck = true;
- };
- };
- };
- };
- };
-}
diff --git a/nixos/modules/home-assistant/light.nix b/nixos/modules/home-assistant/light.nix
deleted file mode 100644
index a9d158b..0000000
--- a/nixos/modules/home-assistant/light.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-[
- {
- name = "RGB Osvětlení";
- command_topic = "homeassistant/led-strip";
- brightness_scale = 100;
- brightness_command_topic = "bigclown/node/power-controller:0/led-strip/-/brightness/set";
- #brightness_state_topic = "bigclown/node/power-controller:0/led-strip/-/brightness/set";
- rgb_command_template = ''"#{{"%02x" % red}}{{"%02x" % green}}{{"%02x" % blue}}"'';
- rgb_command_topic = "bigclown/node/power-controller:0/led-strip/-/color/set";
- #rgb_value_template = ''{{int(value[2:4],16)}},{{int(value[5:7],16)}},{{int(value[8:10],16)}}'';
- #rgb_state_topic = "bigclown/node/power-controller:0/led-strip/-/color/set";
- }
-]
diff --git a/nixos/modules/home-assistant/sensors.nix b/nixos/modules/home-assistant/sensors.nix
deleted file mode 100644
index fadd4eb..0000000
--- a/nixos/modules/home-assistant/sensors.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-[
- {
- name = "Teplota";
- state_class = "measurement";
- state_topic = "bigclown/node/climate-monitor:0/thermometer/0:0/temperature";
- unit_of_measurement = "°C";
- }
- {
- name = "Vlhkost";
- state_class = "measurement";
- state_topic = "bigclown/node/climate-monitor:0/hygrometer/0:4/relative-humidity";
- unit_of_measurement = "%";
- }
- {
- name = "Osvětlení";
- state_class = "measurement";
- state_topic = "bigclown/node/climate-monitor:0/lux-meter/0:0/illuminance";
- }
-]