nixos-config/machines/raspite/services/hass.nix

239 lines
6.4 KiB
Nix

{ config, pkgs, ... }:
{
services.home-assistant = {
enable = true;
openFirewall = false;
config = {
logger = {
logs = {
homeassistant.helpers.llm = "debug";
homeassistant.components.conversation.chat_log = "debug";
homeassistant.components.openai_conversation = "debug";
};
};
http = {
server_host = "127.0.0.1";
use_x_forwarded_for = true;
trusted_proxies = [ "127.0.0.1" ];
};
assist_pipeline = { };
backup = { };
bluetooth = { };
config = { };
conversation = { };
history = { };
recorder = {
purge_keep_days = 14;
};
homeassistant_alerts = { };
image_upload = { };
logbook = { };
media_source = { };
mobile_app = { };
my = { };
ssdp = { };
stream = { };
sun = { };
usb = { };
webhook = { };
zeroconf = { };
};
extraPackages =
python3Packages: with python3Packages; [
# speed up aiohttp
isal
zlib-ng
];
extraComponents = [
"mqtt"
"roborock"
"openai_conversation"
];
};
systemd.services.home-assistant.environment = {
OPENAI_BASE_URL = "https://ark.cn-beijing.volces.com/api/v3";
};
services.esphome = {
enable = true;
openFirewall = false;
};
users.groups.dialout.members = config.users.groups.wheel.members;
services.mosquitto = {
enable = true;
};
services.zigbee2mqtt = {
enable = true;
package = pkgs.zigbee2mqtt_2;
settings = {
home-assistant = config.services.home-assistant.enable;
serial = {
adapter = "zstack";
port = "/dev/ttyUSB0";
};
frontend = {
enabled = true;
port = 15313;
host = "127.0.0.1";
};
advanced = {
log_level = "debug";
availability = {
# Periodically check whether devices are online/offline
enabled = true;
};
channel = 11;
homeassistant_legacy_entity_attributes = false;
homeassistant_legacy_triggers = false;
legacy_api = false;
legacy_availability_payload = false;
};
device_options = {
legacy = false;
};
devices = {
"0x000d6f001673c5d4" = {
friendly_name = "";
};
"0x000d6f001673c1df" = {
friendly_name = "";
};
"0x000d6f0014cbc2c6" = {
friendly_name = "";
};
"0x8cf681fffe0a5e38" = {
friendly_name = "";
description = "1: 2: ";
};
"0x8cf681fffe0d9f1c" = {
friendly_name = "1";
description = "1: 2: 西";
};
"0x000d6f00167839ff" = {
friendly_name = "2";
description = "1: 2: ";
};
"0x8cf681fffe0db266" = {
friendly_name = "3";
description = "";
};
"0x8cf681fffe0d9ccb" = {
friendly_name = "4";
description = "1.";
};
"0x000d6f001673c512" = {
friendly_name = "";
};
"0xa4c13815e2f92d74" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54ced3" = {
friendly_name = "西";
transition = 1;
};
"0x540f57fffe54c8d4" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c82b" = {
friendly_name = "西";
transition = 1;
};
"0x540f57fffe5210bc" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c851" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54ce63" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c8ce" = {
friendly_name = "";
transition = 1;
};
"0xa4c138693a2afad7" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c826" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe521114" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c86b" = {
friendly_name = "西";
transition = 1;
};
"0x540f57fffe54c82e" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe5210e3" = {
friendly_name = "";
transition = 1;
};
"0xfc4d6afffe6eb9e3" = {
friendly_name = "";
};
"0x540f57fffe5210cf" = {
friendly_name = "1";
transition = 1;
};
"0x540f57fffe54c8bb" = {
friendly_name = "2";
transition = 1;
};
"0x540f57fffe5210db" = {
friendly_name = "3";
transition = 1;
};
"0x540f57fffe54cec5" = {
friendly_name = "1";
transition = 1;
};
"0x540f57fffe520d1d" = {
friendly_name = "2";
transition = 1;
};
"0x540f57fffe54c966" = {
friendly_name = "3";
transition = 1;
};
"0x540f57fffe520ceb" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe5210cd" = {
friendly_name = "";
transition = 1;
};
};
};
};
networking.firewall.allowedTCPPorts = [ 8443 ];
services.caddy = {
enable = true;
virtualHosts = {
"raspite.coho-tet.ts.net".extraConfig = ''
reverse_proxy ${config.services.home-assistant.config.http.server_host}:${toString config.services.home-assistant.config.http.server_port}
'';
"https://raspite.coho-tet.ts.net:8080".extraConfig = ''
reverse_proxy ${config.services.zigbee2mqtt.settings.frontend.host}:${toString config.services.zigbee2mqtt.settings.frontend.port}
'';
};
};
}