{ depot, lib, pkgs, ... }: let inherit (depot.ops) secrets; in { services.home-assistant = { enable = true; autoExtraComponents = true; applyDefaultConfig = true; configWritable = true; lovelaceConfigWritable = true; config = { homeassistant = { name = "117 Malden Road"; time_zone = "Europe/London"; external_url = "https://ha.lukegb.com"; internal_url = "https://ha.lukegb.com"; }; notify = [{ name = "pushover-luke"; platform = "pushover"; api_key = secrets.pushover.tokens.home-assistant; user_key = secrets.pushover.userKey; }]; http = { use_x_forwarded_for = true; trusted_proxies = [ "::1" "127.0.0.1" ]; }; lifx.light = {}; light = [{ platform = "group"; name = "Bedroom Lights"; entities = map (x: "light.overhead_${x.side}_${x.n}") (lib.cartesianProductOfSets { side = [ "left" "right" ]; n = [ "1" "2" "3" "4" ]; }); }]; cast = {}; plex = {}; default_config = {}; }; lovelaceConfig = { title = "117 Malden Road"; views = [{ title = "Bedroom Lights"; cards = [{ type = "light"; entity = "light.bedroom_lights"; } { type = "light"; entity = "light.bedside_lamp"; icon = "mdi:webcam"; }]; }]; }; }; security.acme.certs."ha.lukegb.com" = { dnsProvider = "cloudflare"; credentialsFile = secrets.cloudflareCredentials; domain = "ha.lukegb.com"; postRun = '' systemctl reload nginx ''; }; services.nginx.virtualHosts."ha.lukegb.com" = { forceSSL = true; useACMEHost = "ha.lukegb.com"; locations."/" = { proxyPass = "http://localhost:8123/"; proxyWebsockets = true; }; }; }