From 40460b870c9a4657ab8d5907f8172f7285f7079b Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Mon, 28 Apr 2025 23:48:32 +0200 Subject: [PATCH] fix: avoid duplicate config for services.home-assistant --- .../home-assistant/default.nix | 128 +++++++++--------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/modules/cloonar-assistant/home-assistant/default.nix b/modules/cloonar-assistant/home-assistant/default.nix index 96fe21e..3b19bee 100644 --- a/modules/cloonar-assistant/home-assistant/default.nix +++ b/modules/cloonar-assistant/home-assistant/default.nix @@ -83,6 +83,70 @@ in "mobile_app" "backup" ]; + + extraPackages = ps: with ps; [ + mysqlclient + ]; + + config = + let + hiddenEntities = [ + "sensor.last_boot" + "sensor.date" + ]; + in + { + recorder = { + db_url = "mysql://hass@localhost/hass?unix_socket=/var/run/mysqld/mysqld.sock"; + }; + homeassistant = { + name = "Home"; + latitude = "!secret home_latitude"; + longitude = "!secret home_longitude"; + elevation = "!secret home_elevation"; + unit_system = "metric"; + currency = "EUR"; + country = "AT"; + time_zone = "Europe/Vienna"; + external_url = "https://${domain}"; + }; + zone = { + name = "Home"; + latitude = "!secret home_latitude"; + longitude = "!secret home_longitude"; + radius = 35; + icon = "mdi:account-multiple"; + + }; + automation = "!include automations.yaml"; + frontend = { }; + http = { + use_x_forwarded_for = true; + trusted_proxies = [ + "127.0.0.1" + "::1" + ]; + }; + api = { }; + history.exclude = { + entities = hiddenEntities; + domains = [ + "automation" + "updater" + ]; + }; + "map" = { }; + # logbook.exclude.entities = "hiddenEntities"; + logger = { + default = "warning"; + }; + + network = { }; + zeroconf = { }; + system_health = { }; + default_config = { }; + system_log = { }; + }; }; systemd.services.install-hacs = { @@ -104,10 +168,6 @@ in ''; }; - services.home-assistant.extraPackages = ps: with ps; [ - mysqlclient - ]; - services.mysql = { enable = true; package = pkgs.mariadb; @@ -128,66 +188,6 @@ in databases = [ "hass" ]; }; - services.home-assistant.config = - let - hiddenEntities = [ - "sensor.last_boot" - "sensor.date" - ]; - in - { - recorder = { - db_url = "mysql://hass@localhost/hass?unix_socket=/var/run/mysqld/mysqld.sock"; - }; - homeassistant = { - name = "Home"; - latitude = "!secret home_latitude"; - longitude = "!secret home_longitude"; - elevation = "!secret home_elevation"; - unit_system = "metric"; - currency = "EUR"; - country = "AT"; - time_zone = "Europe/Vienna"; - external_url = "https://${domain}"; - }; - zone = { - name = "Home"; - latitude = "!secret home_latitude"; - longitude = "!secret home_longitude"; - radius = 35; - icon = "mdi:account-multiple"; - - }; - automation = "!include automations.yaml"; - frontend = { }; - http = { - use_x_forwarded_for = true; - trusted_proxies = [ - "127.0.0.1" - "::1" - ]; - }; - api = { }; - history.exclude = { - entities = hiddenEntities; - domains = [ - "automation" - "updater" - ]; - }; - "map" = { }; - # logbook.exclude.entities = "hiddenEntities"; - logger = { - default = "warning"; - }; - - network = { }; - zeroconf = { }; - system_health = { }; - default_config = { }; - system_log = { }; - }; - users.users.hass.extraGroups = [ "dialout" ]; networking.firewall.allowedTCPPorts = [ 8123 ]; system.stateVersion = "23.05";