nixos-config/services/home-assistant.nix

104 lines
2.6 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;
mqttPort = 1883;
2022-08-12 12:06:52 +02:00
geniePort = 3232;
in {
2021-02-16 03:43:33 +01:00
# just installed for ConBee firmware updates
2020-10-07 14:37:57 +02:00
environment.systemPackages = with pkgs; [ deconz ];
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-10-25 12:08:38 +02:00
extraComponents = [ "otp" "roku" "sonos" "onvif" "homekit_controller" ];
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";
2020-10-03 16:32:06 +02:00
};
default_config = { };
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";
automation = { };
frontend = { };
mobile_app = { };
zeroconf = { };
ssdp = { };
shopping_list = { };
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
};
2020-10-21 20:54:55 +02:00
mqtt = {
broker = "localhost";
2021-11-23 00:40:06 +01:00
port = mqttPort;
2020-10-21 20:54:55 +02:00
username = "hass";
password = "!secret mqtt_password";
discovery = true;
discovery_prefix = "homeassistant";
};
owntracks = { mqtt_topic = "owntracks/#"; };
2022-01-28 18:03:10 +01:00
alarm_control_panel = [{
platform = "manual";
code = "!secret alarm_code";
arming_time = 30;
delay_time = 20;
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";
host = "http://localhost:${toString geniePort}";
};
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
}