diff --git a/devices/homie/modules/home-assistant/frontend.nix b/devices/homie/modules/home-assistant/frontend.nix index b8f77c9b..c518989c 100644 --- a/devices/homie/modules/home-assistant/frontend.nix +++ b/devices/homie/modules/home-assistant/frontend.nix @@ -1,12 +1,68 @@ -{dracul-ha-src, ...}: { +{ + caule-themes-src, + dracul-ha-src, + lib, + pkgs, + ... +}: let + inherit (lib) concatStringsSep getExe; + inherit (pkgs.writers) writeYAML; + + themes = [ + "${caule-themes-src}/themes/caule-themes-pack-1.yaml" + "${dracul-ha-src}/themes/dracul-ha.yaml" + ]; +in { + systemd.services.home-assistant.preStart = let + WorkingDirectory = "/var/lib/hass"; + in + getExe (pkgs.writeShellApplication { + name = "ha-themes"; + text = '' + mkdir -p ${WorkingDirectory}/themes + cp -f ${concatStringsSep " " themes} ${WorkingDirectory}/themes + ''; + }); + services.home-assistant = { - config = { - # GUI - frontend = { - themes = "!include ${dracul-ha-src}/themes/dracul-ha.yaml"; - }; - lovelace = { + config.frontend = { + themes = "!include_dir_merge_named themes"; + }; + + lovelaceConfig = { + title = "Our House"; + views = [ + { + path = "home"; + title = "Home"; + cards = [ + { + type = "entities"; + entities = [ + "switch.smartplug1" + "switch.smartplug3" + ]; + } + ]; + } + ]; + }; + + config.lovelace.dashboards = { + esphome-dash = { + title = "ESPHome"; + icon = "mdi:car-esp"; mode = "yaml"; + + show_in_sidebar = true; + require_admin = true; + + filename = writeYAML "esphome.yaml" { + strategy = { + type = "iframe"; + url = "https://esphome.nelim.org"; + }; + }; }; }; }; diff --git a/flake.lock b/flake.lock index f1574b1c..a05d6e34 100644 Binary files a/flake.lock and b/flake.lock differ diff --git a/flake.nix b/flake.nix index 7f4d1c26..d0aa3f79 100644 Binary files a/flake.nix and b/flake.nix differ diff --git a/inputs.nix b/inputs.nix index 5b754959..39882892 100644 --- a/inputs.nix +++ b/inputs.nix @@ -226,6 +226,11 @@ let owner = "berti24"; repo = "dracul-ha"; } + { + name = "caule-themes-src"; + owner = "ricardoquecria"; + repo = "caule-themes-pack-1"; + } # Nvim plugins {