summaryrefslogtreecommitdiffstats
path: root/lass/2configs/hass/zigbee.nix
blob: 210c761b561a63244b035a8271cd59eb611f2991 (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
{config, pkgs, lib, ...}: let

  unstable-pkgs = import <nixpkgs-unstable> {};

in {
  # symlink the zigbee controller
  services.udev.extraRules = ''
    SUBSYSTEM=="tty", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a8", SYMLINK+="cc2531", MODE="0660", GROUP="dialout"
    SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="cc2652", MODE="0660", GROUP="dialout"
  '';

  # needed to use unstable package
  systemd.services.zigbee2mqtt.environment.ZIGBEE2MQTT_DATA = "/var/lib/zigbee2mqtt";

  services.zigbee2mqtt = {
    enable = true;
    package = unstable-pkgs.zigbee2mqtt;
    settings = {
      homeassistant = true;
      frontend.port = 1337;
      experimental.new_api = true;
      permit_join = false;
      mqtt = {
        discovery = true;
        base_topic = "zigbee";
        server = "mqtt://10.42.0.1";
        user = "gg23";
        password = "gg23-mqtt";
      };
      serial = {
        port = "/dev/cc2652";
        # disable_led = true;
      };
      advanced = {
        pan_id = 4222;
      };
      devices = let
        set_device = id: name:
          lib.nameValuePair id {
          };
      in {
        # lights https://www.zigbee2mqtt.io/devices/9290022166.html#philips-9290022166
        "0x0017880106ed3bd8".friendly_name = "l_bett";
        "0x0017880108327622".friendly_name = "l_essen";
        "0x0017880106ee2865".friendly_name = "l_arbeit";
        "0x00178801082e9f2f".friendly_name = "l_nass";

        # switches https://www.zigbee2mqtt.io/devices/324131092621.html#philips-324131092621
        "0x00178801086ac38c".friendly_name = "i_bett";
        "0x00178801086ad1fb".friendly_name = "i_essen";
        "0x00178801086ac373".friendly_name = "i_nass";

        # sensors https://www.zigbee2mqtt.io/devices/9290012607.html#philips-9290012607
        "0x0017880106f772f2".friendly_name = "s_essen";
        "0x0017880106f77f30".friendly_name = "s_nass";

        # heat https://www.zigbee2mqtt.io/devices/701721.html#popp-701721
        "0x842e14fffe27109a".friendly_name = "t_bett";
        "0x842e14fffe269a73".friendly_name = "t_nass";
        "0x842e14fffe269a56".friendly_name = "t_arbeit";

        # rotation https://www.zigbee2mqtt.io/devices/E1744.html
        "0x8cf681fffe065493" = {
          friendly_name = "r_test";
          device_id = "r_test";
          simulated_brightness = {
            delta = 2;
            interval = 100;
          };
        };

      };
    };
  };
}