36 lines
778 B
Nix
36 lines
778 B
Nix
|
{
|
||
|
lib,
|
||
|
config,
|
||
|
pkgs,
|
||
|
...
|
||
|
}:
|
||
|
with lib; let
|
||
|
haCfg = config.pub-solar.home-assistant;
|
||
|
cfg = config.pub-solar.home-assistant.zigbee2mqtt;
|
||
|
in {
|
||
|
config = mkIf (haCfg.enable && cfg.enable) {
|
||
|
networking.firewall.allowedTCPPorts = [
|
||
|
8080 # zigbee2mqtt
|
||
|
];
|
||
|
|
||
|
#services.udev.extraRules = ''KERNEL=="${cfg.device}", OWNER="zigbee2mqtt", GROUP="zigbee2mqtt"'';
|
||
|
|
||
|
services.zigbee2mqtt = {
|
||
|
enable = true;
|
||
|
settings = {
|
||
|
frontend = true;
|
||
|
permit_join = false;
|
||
|
homeassistant = true;
|
||
|
mqtt = {
|
||
|
user = "z2m";
|
||
|
password = "!secrets.yaml mqtt_password";
|
||
|
};
|
||
|
serial = {
|
||
|
port = cfg.device;
|
||
|
adapter = mkIf (cfg.adapter != null) cfg.adapter;
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
}
|