From 52d0196dc15557c3ac23a46ce522ef748daeb799 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 6 Oct 2024 05:45:08 -0400 Subject: [PATCH] feat(hass): setup ui declaratively --- .../homie/modules/home-assistant/frontend.nix | 70 ++++++++++++++++-- flake.lock | Bin 53554 -> 54079 bytes flake.nix | Bin 10626 -> 10770 bytes inputs.nix | 5 ++ 4 files changed, 68 insertions(+), 7 deletions(-) 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 f1574b1c9ae0a9b2be94fa3d98ef497f85d36c53..a05d6e34487faa5a0d6be0701a57d2fbd91b53c9 100644 GIT binary patch delta 260 zcmdnAh69CObyTX(wg+RT)S58|S&D zxuz#)F3OzT zxK>m+8OeCvg2d!(UBihVg*6OPlPwZWlFSp6)69%hEX)iol9JPm(o#|^%`8&Pj7-f^ sEiEk)lanR~a(EMG>SRGxgUt;BCcP>sRu&f}D_JQhp^I%^F}KSY0BMU_h5!Hn delta 19 bcmdnLjCs={<_(Pko8yFxdp94PUuO&eSFs4F diff --git a/flake.nix b/flake.nix index 7f4d1c2640d86531f3dfd05a1c565a1f94563af5..d0aa3f798107cdeb7d149761ebe09d924c5a99ba 100644 GIT binary patch delta 83 zcmZn)o)og-4KsIgVrfpQZb?RJZtCO(ta?U8naPPoDfxw^smVo|iAvU73Sdx_T9B_` atDuCWyjZs&F*#e;aI&JP>gG4h(^LWFo*cvg delta 12 TcmbOf(iFVm4fEz2mT9U0B~b-Q 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 {