summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2024-12-21 15:12:54 +0100
committerMartin Fischer <martin@push-f.com>2024-12-29 08:52:25 +0100
commitcb42f5cf152641565916e27173fbe020e0f0eb28 (patch)
tree8f4d89f736992c7881eda29011059dc4ea06d79b
parent9ea81efb86ffdb427d3b5a770c00e40c68661d23 (diff)
ev: add zigbee2mqtt and mosquitto
-rw-r--r--nixos/hosts/ev/default.nix5
-rw-r--r--nixos/hosts/ev/home-automation.nix41
2 files changed, 46 insertions, 0 deletions
diff --git a/nixos/hosts/ev/default.nix b/nixos/hosts/ev/default.nix
index ec2ed86..3bdde6d 100644
--- a/nixos/hosts/ev/default.nix
+++ b/nixos/hosts/ev/default.nix
@@ -11,8 +11,13 @@
<top/profiles/server>
<top/shared/tailscale.nix>
<top/shared/basics-physical.nix>
+ ./home-automation.nix
];
+ home-automation.zigbee2mqttPort = 8080;
+
+ home-automation.zigbeeSerialPort = "/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_e2fed465c59ded11962fd7a5a7669f5d-if00-port0";
+
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
diff --git a/nixos/hosts/ev/home-automation.nix b/nixos/hosts/ev/home-automation.nix
new file mode 100644
index 0000000..0766e4e
--- /dev/null
+++ b/nixos/hosts/ev/home-automation.nix
@@ -0,0 +1,41 @@
+# I'm not using Home Assistant because many of its integrations can only be configured via the UI.
+# (see https://github.com/home-assistant/architecture/blob/master/adr/0010-integration-configuration.md)
+
+{ config, lib, pkgs, ... }:
+
+let
+ cfg = config.home-automation;
+in
+{
+ options.home-automation = {
+ zigbee2mqttPort = lib.mkOption {
+ type = lib.types.int;
+ };
+ zigbeeSerialPort = lib.mkOption {
+ type = lib.types.str;
+ };
+ };
+
+ config = {
+ services = {
+ zigbee2mqtt = {
+ enable = true;
+ settings = {
+ serial = {
+ port = cfg.zigbeeSerialPort;
+ };
+ frontend = {
+ port = cfg.zigbee2mqttPort;
+ };
+ };
+ };
+
+ mosquitto = {
+ enable = true;
+ };
+
+ # TODO: somehow record a history of events (perhaps in Grafana?)
+ # TODO: somehow set up some automations
+ };
+ };
+}