-
Notifications
You must be signed in to change notification settings - Fork 0
/
mqtt.nix
43 lines (39 loc) · 1.19 KB
/
mqtt.nix
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
{ config, lib, ... }:
let
addresses = config.gradient.const.wireguard.addresses;
ports = import ./misc/service-ports.nix;
asiyahPorts = import ../asiyah/misc/service-ports.nix;
in
{
services.zigbee2mqtt = {
enable = true;
settings = {
homeassistant = config.services.home-assistant.enable;
mqtt = {
server = "mqtt://${addresses.gradientnet.asiyah}:${toString asiyahPorts.mqtt}";
include_device_information = true;
version = 5;
};
serial = {
port = "/dev/serial/by-id/usb-ITEAD_SONOFF_Zigbee_3.0_USB_Dongle_Plus_V2_20231121193348-if00";
baudrate = 115200;
adapter = "ember";
};
availability = true;
frontend = {
port = ports.zigbee2mqtt;
};
advanced = {
cache_state = true;
last_seen = "ISO_8601";
elapsed = true;
};
};
};
systemd.services.zigbee2mqtt.serviceConfig = {
Restart = lib.mkForce "always"; # Sometimes fails with successful exit code
RestartSec = 10;
};
networking.firewall.interfaces.gradientnet.allowedTCPPorts = [ ports.zigbee2mqtt ];
networking.firewall.interfaces.gradientnet.allowedUDPPorts = [ ports.zigbee2mqtt ];
}