Files
nixos/hosts/genesis/home-assistant.nix
T

136 lines
3.6 KiB
Nix
Raw Normal View History

2023-06-29 00:27:30 -05:00
{ config, pkgs, ... }:
let
service_list = [ "podman-home-assistant.service" ];
in
{
virtualisation.podman.enable = true;
services.home-assistant = {
enable = true;
configDir = "/var/lib/hass";
2024-09-17 15:54:53 -05:00
extraComponents = [
"accuweather"
"calendar"
"cast"
"eufy"
"lovelace"
"nextcloud"
"ping"
"piper"
"radio_browser"
"rainbird"
"roborock"
"smart_meter_texas"
"speedtestdotnet"
"solaredge"
"whisper"
"wiz"
"wyoming"
"zwave_js"
];
customComponents = with pkgs.home-assistant-custom-components; [
smartthinq-sensors
];
2023-06-29 00:27:30 -05:00
config = {
default_config = {};
tts = [ { platform = "google_translate"; } ];
http = {
use_x_forwarded_for = true;
trusted_proxies = [ "127.0.0.1" "::1" ];
server_host = "127.0.0.1";
};
#"automation manual" = *nix config here* and so on
2023-08-26 20:02:09 -05:00
"automation ui" = "!include automations.yaml";
"script ui" = "!include scripts.yaml";
"scene ui" = "!include scenes.yaml";
2023-06-29 00:27:30 -05:00
};
};
2024-02-13 15:09:50 -06:00
# Helps with Voice stuff for Home Assistant
services.wyoming = {
faster-whisper.servers = {
greg = {
enable = true;
beamSize = 1; # wut?
device = "auto"; # Could be CPU or CUDA
language = "en";
model = "base-int8";
uri = "tcp://0.0.0.0:13415";
};
};
piper.servers.greg = {
enable = true;
uri = "tcp://0.0.0.0:13416";
voice = "en_US-amy-medium";
};
};
2023-06-29 00:27:30 -05:00
# Although NixOS has a package for Home Assistant, it is not kept as up to date as the container and the upstream
# is very vocal about only supporting their own container or the HAOS deployments. So we deploy the container here
# and avoid any potential messes from that
virtualisation.oci-containers = {
backend = "podman";
# I have ZWave devices. The easiest way to connect to them is the zwavejs2mqtt service running, so we spin up
# its container and map the ZWave device into it
containers.zwave = {
2024-02-20 09:55:08 -06:00
autoStart = false; # We will try to start it with udev.extraRules listed below, as this option starts it too quickly
2023-08-31 08:01:46 -05:00
image = "zwavejs/zwave-js-ui:latest";
2023-06-29 00:27:30 -05:00
ports = [ "8091:8091" "3000:3000" ];
volumes = [ "/var/lib/zwave:/usr/src/app/store" ];
extraOptions = [
"--device" "/dev/serial/by-id/usb-0658_0200-if00:/dev/zwave"
"--pull=newer"
];
2023-08-31 08:01:46 -05:00
environment = {
TZ = "America/Chicago";
2024-03-25 15:18:53 -05:00
CONSOLE_OUTPUT = "true";
2023-08-31 08:01:46 -05:00
};
2023-06-29 00:27:30 -05:00
};
};
# Both of the above container need storage for their configuration and devices, but it is not created correctly by
# the container. So we add the creation of /var/lib/{zwave,hass} to the systemd Unit files
systemd.services = {
2024-08-16 11:56:49 -05:00
"podman-zwave" = {
after = [ "sys-devices-pci0000:00-0000:00:1e.0-0000:02:1b.0-usb2-2\\x2d1-2\\x2d1:1.0-tty-ttyACM0.device" ];
wantedBy = [ "sys-devices-pci0000:00-0000:00:1e.0-0000:02:1b.0-usb2-2\\x2d1-2\\x2d1:1.0-tty-ttyACM0.device" ];
serviceConfig = {
StateDirectory = "zwave";
StateDirectoryMode = pkgs.lib.mkForce "0777";
};
2023-06-29 00:27:30 -05:00
};
};
2024-02-20 09:55:08 -06:00
services.udev.extraRules = ''
2024-08-16 11:56:49 -05:00
SUBSYSTEM=="tty", KERNEL=="ttyACM0", TAG+="systemd"
2024-02-20 09:55:08 -06:00
'';
2023-06-29 00:27:30 -05:00
2023-08-22 00:40:32 -05:00
greg.proxies = {
2023-09-05 11:06:35 -05:00
"smart.home".target = "http://127.0.0.1:8123/";
2023-12-29 22:40:23 -06:00
"smart.thehellings.lan".target = "http://127.0.0.1:8123/";
2023-09-05 11:06:35 -05:00
"zwave.home".target = "http://127.0.0.1:8091/";
2023-08-22 00:40:32 -05:00
};
2023-06-29 00:27:30 -05:00
# Ensure that both ports are up and running. We keep 8123 directly open because we are on the LAN and sometimes want to connect
# directly for troubleshooting Nginx configuration
networking.firewall = {
2023-09-05 11:06:35 -05:00
allowedTCPPorts = [ 80 443 ];
2023-06-29 00:27:30 -05:00
};
greg.backup.jobs.zwave = {
src = "/var/lib/zwave";
dest = "zwave";
2024-08-15 00:34:28 -05:00
id = "zwave-asdf";
2023-06-29 00:27:30 -05:00
};
2024-02-14 00:12:27 -06:00
2024-08-15 00:34:28 -05:00
greg.backup.jobs.hass-backup = {
2024-02-14 00:12:27 -06:00
src = "/var/lib/hass";
dest = "hass";
2024-08-15 00:34:28 -05:00
id = "hass-asdf";
2024-02-14 00:12:27 -06:00
};
2023-06-29 00:27:30 -05:00
}