2023-06-12 15:04:12 +00:00
|
|
|
{
|
|
|
|
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 = [
|
2023-10-01 20:20:38 +00:00
|
|
|
8081 # zigbee2mqtt
|
2023-06-12 15:04:12 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
services.zigbee2mqtt = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
2023-10-01 20:20:38 +00:00
|
|
|
frontend = {
|
|
|
|
port = 8081;
|
|
|
|
};
|
2023-06-12 15:04:12 +00:00
|
|
|
permit_join = false;
|
2023-11-11 00:12:57 +00:00
|
|
|
homeassistant = {
|
|
|
|
legacy_entity_attributes = false;
|
|
|
|
};
|
2023-10-01 20:20:38 +00:00
|
|
|
availability = true;
|
|
|
|
advanced = {
|
2023-11-11 00:12:57 +00:00
|
|
|
legacy_api = false;
|
2023-10-01 20:20:38 +00:00
|
|
|
legacy_availability_payload = false;
|
|
|
|
};
|
2023-06-12 15:04:12 +00:00
|
|
|
mqtt = {
|
|
|
|
user = "z2m";
|
|
|
|
password = "!secrets.yaml mqtt_password";
|
|
|
|
};
|
|
|
|
serial = {
|
|
|
|
port = cfg.device;
|
|
|
|
adapter = mkIf (cfg.adapter != null) cfg.adapter;
|
|
|
|
};
|
2023-10-01 20:20:38 +00:00
|
|
|
groups = "groups.yaml";
|
2023-11-11 00:12:57 +00:00
|
|
|
ota = {
|
|
|
|
zigbee_ota_override_index_location = "/var/lib/zigbee2mqtt/index.json";
|
|
|
|
};
|
2023-06-12 15:04:12 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|