summaryrefslogtreecommitdiff
path: root/nixos/hosts/ev/home-automation.nix
blob: 0766e4e454a28838ea803efc840fcf9f0fcfaf5e (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
# 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
    };
  };
}