nixos-config/services/home-assistant/default.nix

101 lines
2.4 KiB
Nix
Raw Normal View History

2020-10-11 10:49:06 +02:00
{ config, pkgs, ... }:
2020-10-03 16:32:06 +02:00
with pkgs;
2020-10-21 20:54:55 +02:00
let
port = config.services.home-assistant.config.http.server_port;
2022-08-12 12:06:52 +02:00
geniePort = 3232;
in {
imports = [ ./esphome.nix ];
2021-02-16 03:43:33 +01:00
# just installed for ConBee firmware updates
2023-05-31 17:25:46 +02:00
# TODO deconz package is currently broken
# environment.systemPackages = with pkgs; [ deconz ];
2020-10-07 14:37:57 +02:00
2020-10-22 19:15:55 +02:00
services.nginx = {
virtualHosts."${config.networking.domain}" = {
enableACME = true;
forceSSL = true;
extraConfig = ''
proxy_buffering off;
'';
locations."/" = {
proxyPass = "http://[::1]:${toString port}";
proxyWebsockets = true;
};
2020-10-22 19:15:55 +02:00
};
};
2020-10-21 20:54:55 +02:00
2020-10-03 16:32:06 +02:00
services.home-assistant = {
enable = true;
openFirewall = true;
2022-12-29 13:02:51 +01:00
extraComponents = [
"default_config"
"otp"
"esphome"
2022-12-29 13:02:51 +01:00
"homekit_controller"
"fritz"
2022-12-29 13:02:51 +01:00
"roku"
"sonos"
"onvif"
"shopping_list"
];
2020-10-03 16:32:06 +02:00
config = {
homeassistant = {
name = "Home";
latitude = "!secret latitude";
longitude = "!secret longitude";
elevation = 42;
2020-10-03 16:32:06 +02:00
unit_system = "metric";
temperature_unit = "C";
external_url = "https://home.felschr.com";
internal_url = "http://192.168.1.102:8123";
media_dirs.media = "/media";
2020-10-03 16:32:06 +02:00
};
default_config = { };
http = {
use_x_forwarded_for = true;
trusted_proxies = [ "::1" ];
};
"automation editor" = "!include automations.yaml";
"scene editor" = "!include scenes.yaml";
"script editor" = "!include scripts.yaml";
2021-02-16 03:43:33 +01:00
zha = {
database_path = "/var/lib/hass/zigbee.db";
zigpy_config = { ota = { ikea_provider = true; }; };
2020-10-07 14:37:57 +02:00
};
2022-01-28 18:03:10 +01:00
alarm_control_panel = [{
platform = "manual";
code = "!secret alarm_code";
arming_time = 30;
2022-10-26 18:44:29 +02:00
delay_time = 30;
2022-01-28 18:03:10 +01:00
trigger_time = 120;
disarmed = { trigger_time = 0; };
armed_home = {
arming_time = 0;
delay_time = 0;
};
}];
2022-08-12 12:06:52 +02:00
almond = {
type = "local";
2022-12-29 14:24:12 +01:00
host = "http://localhost:${toString geniePort}/me";
2022-08-12 12:06:52 +02:00
};
2020-10-03 16:32:06 +02:00
};
# configWritable = true; # doesn't work atm
};
2022-10-25 12:08:38 +02:00
networking.firewall.allowedTCPPorts = [
1400 # Sonos discovery
];
networking.firewall.allowedUDPPorts = [
5353 # HomeKit
];
age.secrets.hass-secrets = {
file = ../../secrets/hass/secrets.age;
path = "/var/lib/hass/secrets.yaml";
owner = "hass";
group = "hass";
};
2020-10-03 16:32:06 +02:00
}