feat(hosts/server/nixcloud): home assistant refactor and delcarative UI#554
feat(hosts/server/nixcloud): home assistant refactor and delcarative UI#554DaRacci wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis pull request implements a comprehensive refactoring of the Home Assistant Nix-based dashboard configuration by extracting centralised entity and utility libraries, reorganising button-card components into a modular directory structure, and updating views to reference dynamic entity identifiers. A new bedroom AC adaptive fan speed automation is also introduced. Changes
Possibly Related Issues
Poem
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~50 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 Do not merge outdated PRsWaiting for
This rule is failing.Make sure PRs are almost up to date before merging
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
There was a problem hiding this comment.
Actionable comments posted: 25
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
hosts/server/nixcloud/home-assistant/default.nix (1)
89-92:⚠️ Potential issue | 🟡 MinorFile mode 0755 is overly permissive for YAML configuration files.
The
automations.yamlandscenes.yamlfiles are being created with mode0755, which sets executable bits and allows world read access. Configuration files should typically use0644(owner read/write, others read) or0640(owner read/write, group read).🔧 Proposed fix
systemd.tmpfiles.rules = [ - "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass" - "f ${config.services.home-assistant.configDir}/scenes.yaml 0755 hass hass" + "f ${config.services.home-assistant.configDir}/automations.yaml 0644 hass hass" + "f ${config.services.home-assistant.configDir}/scenes.yaml 0644 hass hass" ];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hosts/server/nixcloud/home-assistant/default.nix` around lines 89 - 92, The tmpfiles rules currently create automations.yaml and scenes.yaml with mode 0755 which is too permissive; update the entries in systemd.tmpfiles.rules so those two strings use a safer mode such as 0644 (or 0640 if group-only access is desired) instead of 0755, i.e., modify the lines that reference "${config.services.home-assistant.configDir}/automations.yaml" and "${config.services.home-assistant.configDir}/scenes.yaml" to set the correct octal file mode.hosts/server/nixcloud/home-assistant/music.nix (1)
9-14:⚠️ Potential issue | 🟠 MajorUpdate dashboard configuration to match removed providers.
The spotify provider has been removed from music.nix but remains referenced in multiple dashboard files. This will cause configuration errors:
button-cards.nix:627andbutton-cards/media-player.nix:125referencemedia_player.spotify_jameslib.nix:331andlib.nix:335referencemedia_player.spotifyEither add the spotify provider back to the music.nix providers list, or remove these dashboard references and substitute with available providers (chromecast, hass, hass_players, opensubsonic).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hosts/server/nixcloud/home-assistant/music.nix` around lines 9 - 14, The dashboards still reference removed Spotify entities (media_player.spotify_james and media_player.spotify) causing config errors; either re-add "spotify" to the providers array in music.nix (so the existing dashboard refs work) or update the dashboard files to stop referencing Spotify and substitute available providers (chromecast, hass, hass_players, opensubsonic). Locate the providers list in music.nix and add "spotify" if restoring support, or open button-cards.nix and button-cards/media-player.nix and replace occurrences of media_player.spotify_james and media_player.spotify with the correct entity ids from chromecast/hass/hass_players/opensubsonic (or remove those card/button blocks if not applicable) and update any helper references in lib.nix that mention media_player.spotify accordingly.hosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nix (1)
75-82:⚠️ Potential issue | 🟡 MinorInconsistent user ID handling: one dynamic, one hardcoded.
ids.jamesuses the centralized reference, but"c82f30a396fb42a9a10514fd63d5aac7"remains hardcoded. If this is Savannah's ID, consider usingids.savannah. If it's a different user, add them tostatic.nixfor consistency.Suggested fix
users = [ ids.james - "c82f30a396fb42a9a10514fd63d5aac7" + ids.savannah # or add new user to static.nix ];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nix` around lines 75 - 82, The visibility list mixes a centralized ID reference (ids.james) with a hardcoded UUID string; replace the literal "c82f30a396fb42a9a10514fd63d5aac7" with the appropriate centralized identifier (e.g., ids.savannah) or add a new entry for that user in your static user registry (static.nix) and reference it here; update the visibility block so both users use the ids.<name> symbols for consistency (look for the visibility attribute and the ids.* symbols to modify).hosts/server/nixcloud/home-assistant/dashboard/views/music.nix (1)
113-114: 🧹 Nitpick | 🔵 TrivialConsider centralizing
input_boolean.music_player_idle_helperentity reference.This entity is hardcoded while other entities in this file use
mediaPlayers.*references. For consistency, consider adding this toentities.inputBooleansinlib.nix.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hosts/server/nixcloud/home-assistant/dashboard/views/music.nix` around lines 113 - 114, Replace the hardcoded entity "input_boolean.music_player_idle_helper" in music.nix with a centralized reference from your lib mapping: add a key for music_player_idle_helper under entities.inputBooleans in lib.nix, then update the view in hosts/server/nixcloud/home-assistant/dashboard/views/music.nix to use that reference (e.g., entities.inputBooleans.music_player_idle_helper) instead of the literal string so it matches other mediaPlayers.* usage.hosts/server/nixcloud/home-assistant/dashboard/lib.nix (1)
667-692: 🧹 Nitpick | 🔵 TrivialAPI inconsistency:
mkMushroomTemplateBadgeuses snake_case whilemkEntityuses camelCase.
mkMushroomTemplateBadgeacceptstap_action,double_tap_action(snake_case) at lines 676-677, whilemkEntity(line 646) usestapAction(camelCase). This inconsistency could confuse developers.Consider standardising to camelCase parameters with internal conversion via
parseConvertCompact, consistent withmkEntityandmkButtonCard.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hosts/server/nixcloud/home-assistant/dashboard/lib.nix` around lines 667 - 692, Rename mkMushroomTemplateBadge parameters from snake_case to camelCase (e.g., change tap_action → tapAction and double_tap_action → doubleTapAction) to match mkEntity and mkButtonCard; update the function signature to accept camelCase names and then map/convert those camelCase keys to the snake_case names expected by parseConvertCompact when building the attribute set passed into parseConvertCompact so external API is camelCase while the internal payload remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@hosts/server/nixcloud/home-assistant/automations/bedroom_ac_adaptive_fan_speed.yaml`:
- Around line 54-66: The template for selected_change_sensor/distance_change may
yield 0 when the sensor is missing or returns non-numeric, leading to spurious
fan adjustments; update the template logic around selected_change_sensor,
distance_change, and distance_reduced_by to first detect unavailable/unknown
states (or non-numeric values) and short-circuit the automation (skip
adjustment) when distance_change is zero or not a valid number; specifically,
add a guard check that ensures selected_change_sensor's state is numeric and
non-zero before computing distance_reduced_by or proceeding with fan-speed
calculations in the automation that uses distance_change and
distance_reduced_by.
- Around line 1-6: The automation references missing helper entities so it will
behave incorrectly; add and configure the required helpers: create an
input_datetime named input_datetime.bedroom_ac_fan_last_adjusted for cooldown
tracking, create an input_number named input_number.target_temperature with
appropriate min/max/step and units for the desired target, and define the three
sensors sensor.bedroom_ac_distance_change_5m,
sensor.bedroom_ac_distance_change_10m, and sensor.bedroom_ac_distance_change_15m
(e.g. as template or statistics sensors) so they report the distance-change
values used by the automation; ensure each entity ID exactly matches the names
used in the automation and set sensible initial values/units to avoid
zero/default behavior.
In `@hosts/server/nixcloud/home-assistant/dashboard.nix`:
- Around line 152-153: The lovelace dashboard block uses the wrong option name:
change the property named resource_mode to mode so the Lovelace config uses the
correct key (lovelace -> mode) and set its value to "yaml" or "storage" as
intended; update any references to resource_mode inside the lovelace block to
use mode so Home Assistant recognizes the dashboard configuration.
In `@hosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nix`:
- Line 42: The dashboard admin-panel references templates
"nav_button_state_small" and "nav_button_small" but button-cards/default.nix
currently only exports "media-player"; update button-cards/default.nix to export
both "nav_button_state_small" and "nav_button_small" (and ensure their template
definitions exist in the button card templates file), so the templates used by
admin-panel.nix are available at import time.
In `@hosts/server/nixcloud/home-assistant/dashboard/components/button-cards.nix`:
- Around line 1076-1220: The custom_card_user template hardcodes person entities
in custom_fields.one, two, and three (e.g., states["person.james"]) which
reduces reusability; change the template to accept variables (e.g.,
variables.person1, variables.person2, variables.person3) and update the JS in
custom_fields.one, two, three to read states[variables.person1] etc., providing
sensible fallbacks if a variable is missing, so callers can pass different
person entity IDs without editing the template.
- Around line 653-681: The unbounded animation loop in the update() function
(which calls requestAnimationFrame(update)) must be stopped when the card is not
visible or removed: store the requestAnimationFrame handle (e.g., let rafId),
before scheduling the next frame check visibility/document.visibilityState ===
'visible' and that the element (elt or card) is still connected
(elt.isConnected); only then call rafId = requestAnimationFrame(update),
otherwise call cancelAnimationFrame(rafId) and/or stop scheduling further
frames; alternatively replace the tight RAF loop with a setInterval for a lower
frequency and clearInterval when elt is removed (use elt.isConnected or a
MutationObserver) so the bar update cleans up properly.
- Around line 440-456: The code compares Home Assistant state values to numeric
floats (e.g., states["input_number.hp_book"].state == 1.0) but HA state values
are strings; update the conditional logic in the block that checks
states["input_select.audiobook"] and states["input_number.hp_book"].state to
either parse the state to a number (e.g.,
Number(states["input_number.hp_book"].state)) before comparing to numeric
literals or compare against string literals ("1", "2", etc.), and keep the same
return paths for the HP image strings.
- Around line 1-2: The top-level use of "with (import ../lib.nix { inherit lib;
});" hides which functions from lib are used; replace this module-level
with-binding by creating a let block that imports ../lib.nix and explicitly
inherits only the symbols you use (e.g., let libPkg = import ../lib.nix {
inherit lib; }; in { inherit (libPkg) <list-of-functions>; } ), remove the
with(...) wrapper, and update all references to use the inherited names; ensure
you list the actual functions/constants you consume from lib so dependencies are
explicit.
In
`@hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nix`:
- Around line 1-6: The dashboard import now only loads button-cards/default.nix
which exports only media-player, leaving the old button-cards.nix orphaned and
breaking templates; fix by either (A) migrating all template definitions (setup,
nav_button_small, nav_button_state_small, custom_card_alarm_bottom,
custom_card_mediaplayer_music, custom_card_timer_bottom,
custom_card_mediaplayer_bottom) from the old button-cards.nix into
button-cards/default.nix and re-exporting them alongside media-player, or (B)
revert the import in dashboard/default.nix to load the original button-cards.nix
instead of the directory; locate the import call (import
./components/button-cards { inherit lib; }) and ensure the chosen templates are
available under that module name so all references (e.g., setup,
nav_button_small, custom_card_mediaplayer_music) resolve.
In
`@hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/media-player.nix`:
- Around line 156-184: The requestAnimationFrame loop started in the bar
insertion block (functions update and the requestAnimationFrame calls) has no
cleanup or guard and will spin indefinitely and create duplicates on re-renders;
modify this block to store the animation frame id (rafId) when scheduling
requestAnimationFrame, check for an existing rafId before starting a new loop to
prevent multiple concurrent loops, and cancelAnimationFrame(rafId) when the
element is removed or when media is stopped/unavailable (e.g., detect
elt.isConnected or attach a MutationObserver or disconnectedCallback handler) so
update() stops running after cleanup; target the update function, the initial
requestAnimationFrame call, and the element lifecycle/disconnect handling (ids:
update, requestAnimationFrame, card/container/bar) to implement the guard and
cancelation.
- Around line 1-8: Replace the module-level "with (import ../../lib.nix {
inherit lib; });" usage with an explicit let/inherit pattern so you do not
pollute scope; import the ../../lib.nix result into a local name (e.g. let
libnix = import ../../lib.nix { inherit lib; };) and then inherit only the
required symbols into this file's scope instead of using with; update any
references that relied on implicit scope from the with (such as template,
variables, icon_1, accent_color) to reference the explicitly imported/inherited
names.
- Around line 135-154: The styles object inside the mkButtonCard call for album
uses camelCase property names that must be converted to kebab-case to match
custom:button-card expectations; update the nested styles within album (the card
and label blocks) by replacing boxShadow→box-shadow, borderRadius→border-radius,
justifySelf→justify-self, alignSelf→align-self, fontWeight→font-weight,
fontSize→font-size, marginBottom→margin-bottom (and any other camelCased style
keys) so the styles object under mkButtonCard.album.label and
mkButtonCard.album.card uses kebab-case keys throughout.
In `@hosts/server/nixcloud/home-assistant/dashboard/components/navbar.nix`:
- Around line 80-86: The hidden logic uses a hardcoded remote.apple_tv while
other entities use dynamic references (e.g., mediaPlayers.special.music); add a
remotes.apple_tv entry to the entities block in lib.nix (e.g., remotes = {
apple_tv = "remote.apple_tv"; }) and update the navbar.nix hidden expression to
reference the dynamic entity (use the same pattern as
mediaPlayers.special.music, e.g., states['${remotes.apple_tv}']). Also apply the
same replacement for the TV route hidden logic that currently hardcodes
remote.apple_tv.
In
`@hosts/server/nixcloud/home-assistant/dashboard/components/templates/popup.nix`:
- Around line 1-2: Remove the unused module-level "with (import ../../lib.nix {
inherit lib; });" import: the file already receives "lib" via the argument
pattern "{ lib, ... }" and nothing from the imported library is referenced, so
delete the entire with/import expression to avoid polluting scope and hiding
dependencies; ensure the leading "{ lib, ... }:" signature remains and run a
quick lint to confirm no symbols from ../../lib.nix are needed elsewhere in this
file.
In `@hosts/server/nixcloud/home-assistant/dashboard/default.nix`:
- Around line 4-6: The import for button_card_templates now only provides the
media-player template (see button_card_templates and
./components/button-cards/default.nix); update the ./components/button-cards
module to export every template referenced by the dashboard (add missing
templates such as any camera, light, sensor, thermostat templates used in
views), and ensure the top-level export object in default.nix includes those
keys so button_card_templates contains the full set used by the dashboard pages.
In `@hosts/server/nixcloud/home-assistant/dashboard/lib.nix`:
- Line 616: The deprecation warning message passed to lib.warn is
unprofessional; locate the lib.warn call that logs "Convert to mkEntity, shit
stain" (within the parseConvertCompact invocation) and replace the string with a
professional message (e.g., "Deprecated: convert to mkEntity" or similar) so the
warning remains informative but respectful; ensure you update only the literal
message passed to lib.warn and preserve surrounding code and context.
- Around line 218-222: The jsMatch default currently returns an empty string
("''") which can cause music_assistant.transfer_queue to be invoked with an
empty source_player; change the default in the jsMatch expression from "''" to a
sensible fallback entity ID (for example a known room like
mediaPlayers.rooms.everywhere or a configured fallback) or make it
null/undefined and update the tap_action to validate before calling
music_assistant.transfer_queue; specifically, update the jsMatch default and add
a guard in the tap_action (or its calling function) to skip the transfer if
source_player is empty/null so transfer_queue is never invoked with an empty
source_player.
- Around line 144-157: The CSS numeric values in the dashboard style attributes
(icon, img_cell, name, state) are missing units and may be ignored; update the
numeric literals (e.g., width = 20, font-size = 10, font-size = 15) to strings
that include units like "20px", "10px", "15px" so the card CSS is explicit and
reliable—locate the icon and img_cell attribute sets and the name and state
arrays in lib.nix and change the numeric assignments to unit-bearing string
values.
- Around line 138-142: The grid-template-areas value under the grid attribute is
incorrectly quoted (currently producing `" 'i n' 'i s' "`); update the grid
entry for grid-template-areas so each row is a separately quoted string without
embedded single quotes (i.e., produce `"i n" "i s"` as the CSS value) by
changing the existing value assigned to grid-template-areas in the grid
attribute definition.
In `@hosts/server/nixcloud/home-assistant/dashboard/views/energy.nix`:
- Around line 54-58: Replace the hardcoded entity "sensor.power_consumption" in
the history-graph block with the centralized reference from the PR's entities
map in lib.nix; update the energy view (energy.nix) to use the shared entities
map key (e.g., entities.powerConsumption or the exact key used in lib.nix) so
the history-graph's entities array references the centralized symbol rather than
the literal string.
In `@hosts/server/nixcloud/home-assistant/dashboard/views/home.nix`:
- Around line 27-435: Replace the hardcoded entity IDs used in the Bedroom popup
(examples: binary_sensor.bedroom_presence_sensor,
binary_sensor.bedroom_window_sensor, binary_sensor.bedroom_door_sensor,
climate.bedroom_ac, input_boolean.bedroom_occupancy,
input_boolean.bedroom_night_mode, media_player.bedroom_speakers,
sensor.bedroom_next_timer, lighting.bedroom_light, and related switches) with
centralized references defined in lib.nix (e.g., entities.bedroom.<name>) and
update usages in the mkBubbleCard, mkEntity, mkHeading badges, mkButtonCard
templates, mkConditional condState blocks, mkSwipeCard custom_fields, and
template.getState calls so they pull from the new entity constants instead of
literal strings; add the corresponding entries to lib.nix (following the
existing entities structure) and ensure
template.returnIcon/template.remainingTime usages continue to work with the new
references.
- Around line 245-249: The entity string in the mkButtonCard for "Top Light" is
using the wrong domain prefix; update the entity value in the mkButtonCard block
(the card with name "Top Light" and template "light_rgb") from
"lighting.bedroom_light" to "light.bedroom_light" so Home Assistant can resolve
the entity.
- Around line 174-177: The card for mkButtonCard referencing entity
"input_boolean.going_to_bed" has an incorrect name "Waking Up"; update the name
property in that mkButtonCard block to "Going to Bed" so the label matches the
entity (look for the mkButtonCard block where entity =
"input_boolean.going_to_bed" and change its name value).
- Around line 312-316: The progress bar JS references the wrong entity name:
replace occurrences of states['sensor.bed_room_timer'] with
states['sensor.bedroom_next_timer'] (or make the card entity match) so the
calculation in the inline script (the var state = 100 -
states['sensor.bed_room_timer'].attributes.remaining_perc line) uses the same
entity as the card (sensor.bedroom_next_timer); also scan the surrounding code
for any other mismatched uses of sensor.bed_room_timer and unify them to
sensor.bedroom_next_timer to ensure the progress calculation and conditions work
consistently.
In `@hosts/server/nixcloud/home-assistant/static.nix`:
- Around line 3-23: The file static.nix defines an unused Home Assistant static
configuration (entities, users with keys james and savannah, rooms) but is not
imported anywhere; either remove static.nix entirely or integrate it by adding
it to your Nix module imports (e.g., include it from default.nix's imports list)
and consolidate duplicate user definitions with dashboard/lib.nix (remove
duplicates there or merge into a single source of truth) so only one canonical
users definition (james, savannah) remains; update imports and references
accordingly to avoid orphaned files.
---
Outside diff comments:
In `@hosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nix`:
- Around line 75-82: The visibility list mixes a centralized ID reference
(ids.james) with a hardcoded UUID string; replace the literal
"c82f30a396fb42a9a10514fd63d5aac7" with the appropriate centralized identifier
(e.g., ids.savannah) or add a new entry for that user in your static user
registry (static.nix) and reference it here; update the visibility block so both
users use the ids.<name> symbols for consistency (look for the visibility
attribute and the ids.* symbols to modify).
In `@hosts/server/nixcloud/home-assistant/dashboard/lib.nix`:
- Around line 667-692: Rename mkMushroomTemplateBadge parameters from snake_case
to camelCase (e.g., change tap_action → tapAction and double_tap_action →
doubleTapAction) to match mkEntity and mkButtonCard; update the function
signature to accept camelCase names and then map/convert those camelCase keys to
the snake_case names expected by parseConvertCompact when building the attribute
set passed into parseConvertCompact so external API is camelCase while the
internal payload remains unchanged.
In `@hosts/server/nixcloud/home-assistant/dashboard/views/music.nix`:
- Around line 113-114: Replace the hardcoded entity
"input_boolean.music_player_idle_helper" in music.nix with a centralized
reference from your lib mapping: add a key for music_player_idle_helper under
entities.inputBooleans in lib.nix, then update the view in
hosts/server/nixcloud/home-assistant/dashboard/views/music.nix to use that
reference (e.g., entities.inputBooleans.music_player_idle_helper) instead of the
literal string so it matches other mediaPlayers.* usage.
In `@hosts/server/nixcloud/home-assistant/default.nix`:
- Around line 89-92: The tmpfiles rules currently create automations.yaml and
scenes.yaml with mode 0755 which is too permissive; update the entries in
systemd.tmpfiles.rules so those two strings use a safer mode such as 0644 (or
0640 if group-only access is desired) instead of 0755, i.e., modify the lines
that reference "${config.services.home-assistant.configDir}/automations.yaml"
and "${config.services.home-assistant.configDir}/scenes.yaml" to set the correct
octal file mode.
In `@hosts/server/nixcloud/home-assistant/music.nix`:
- Around line 9-14: The dashboards still reference removed Spotify entities
(media_player.spotify_james and media_player.spotify) causing config errors;
either re-add "spotify" to the providers array in music.nix (so the existing
dashboard refs work) or update the dashboard files to stop referencing Spotify
and substitute available providers (chromecast, hass, hass_players,
opensubsonic). Locate the providers list in music.nix and add "spotify" if
restoring support, or open button-cards.nix and button-cards/media-player.nix
and replace occurrences of media_player.spotify_james and media_player.spotify
with the correct entity ids from chromecast/hass/hass_players/opensubsonic (or
remove those card/button blocks if not applicable) and update any helper
references in lib.nix that mention media_player.spotify accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c6a78fa1-39b5-401b-a7da-0712d645922e
📒 Files selected for processing (22)
hosts/server/nixcloud/home-assistant/automations/bedroom_ac_adaptive_fan_speed.yamlhosts/server/nixcloud/home-assistant/dashboard.nixhosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/media-player.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/media_player.nixhosts/server/nixcloud/home-assistant/dashboard/components/decluttering.nixhosts/server/nixcloud/home-assistant/dashboard/components/navbar.nixhosts/server/nixcloud/home-assistant/dashboard/components/templates/popup.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nixhosts/server/nixcloud/home-assistant/dashboard/lib.nixhosts/server/nixcloud/home-assistant/dashboard/templates/button-cards.nixhosts/server/nixcloud/home-assistant/dashboard/views/energy.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nixhosts/server/nixcloud/home-assistant/dashboard/views/music.nixhosts/server/nixcloud/home-assistant/dashboard/views/security.nixhosts/server/nixcloud/home-assistant/dashboard/views/server.nixhosts/server/nixcloud/home-assistant/default.nixhosts/server/nixcloud/home-assistant/music.nixhosts/server/nixcloud/home-assistant/static.nix
💤 Files with no reviewable changes (2)
- hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/media_player.nix
- hosts/server/nixcloud/home-assistant/dashboard/templates/button-cards.nix
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Mergify Merge Queue
- GitHub Check: generate-matrix
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🧰 Additional context used
📓 Path-based instructions (3)
**/*.nix
📄 CodeRabbit inference engine (.opencode/skills/building/SKILL.md)
Use
nix fmtto format Nix code and check syntax
**/*.nix: Runnix fmt <paths...>after making any changes to ensure consistent formatting
Use 2 spaces for indentation in Nix files
Use kebab-case for Nix file and directory names
Use camelCase for Nix attributes (e.g.,myOption,enableFeature)
Use camelCase for Nix option paths (e.g.,services.myService.enable)
Prefer minimal comments; code should be self-explanatory, using comments to explain why, not what
Prefer relative imports over absolute imports (e.g.,./modules/foo.nix)
Group imports at the top of the Nix file and use list format for multiple imports
When generating JSON, YAML, or other structured formats, define as Nix attribute sets and convert using builtins functions (e.g.,builtins.toJSON), rather than using inline string literals
Follow the standard module structure pattern withconfig,lib,pkgsdestructuring,letbindings for module configuration, andoptions/configsections
Useletbindings withinheritfor importing functions from libraries (e.g.,inherit (lib) mkIf mkEnableOption)Run
nix fmtto format code before submitting changes
**/*.nix: Usebuiltins.traceto add trace statements for seeing values during Nix evaluation, withbuiltins.toJSONfor complex attribute sets
Check for circular dependencies in imports or option definitions as the root cause of infinite recursion errors in Nix
Verify attribute names, imports, and option paths to resolve 'attribute missing' errors in Nix configurationsRun
nix fmton changed Nix files after modifying modules
**/*.nix: Declare secrets in Nix usingsops.secretswith the secret path as the key
Specify custom permissions for secrets usingowner,group, andmodeattributes in sops.secrets declarations
Usesops.templatesto combine multiple secrets into configuration files with placeholders
AddrestartUnitsto secret declarations to automatically restart services when secrets change
Use empty `k...
Files:
hosts/server/nixcloud/home-assistant/dashboard.nixhosts/server/nixcloud/home-assistant/default.nixhosts/server/nixcloud/home-assistant/dashboard/views/security.nixhosts/server/nixcloud/home-assistant/dashboard/views/server.nixhosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nixhosts/server/nixcloud/home-assistant/dashboard/views/energy.nixhosts/server/nixcloud/home-assistant/music.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/dashboard/components/templates/popup.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/media-player.nixhosts/server/nixcloud/home-assistant/dashboard/components/navbar.nixhosts/server/nixcloud/home-assistant/static.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nixhosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards.nixhosts/server/nixcloud/home-assistant/dashboard/views/music.nixhosts/server/nixcloud/home-assistant/dashboard/lib.nix
hosts/**/*.nix
📄 CodeRabbit inference engine (.opencode/skills/contributing/SKILL.md)
Test at least one affected host configuration before submitting changes
Files:
hosts/server/nixcloud/home-assistant/dashboard.nixhosts/server/nixcloud/home-assistant/default.nixhosts/server/nixcloud/home-assistant/dashboard/views/security.nixhosts/server/nixcloud/home-assistant/dashboard/views/server.nixhosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nixhosts/server/nixcloud/home-assistant/dashboard/views/energy.nixhosts/server/nixcloud/home-assistant/music.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/dashboard/components/templates/popup.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/media-player.nixhosts/server/nixcloud/home-assistant/dashboard/components/navbar.nixhosts/server/nixcloud/home-assistant/static.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nixhosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards.nixhosts/server/nixcloud/home-assistant/dashboard/views/music.nixhosts/server/nixcloud/home-assistant/dashboard/lib.nix
hosts/{desktop,laptop,server}/**
📄 CodeRabbit inference engine (.opencode/skills/project-structure/SKILL.md)
Per-machine NixOS configurations should be organized in
hosts/<type>/<hostname>/where type is desktop, laptop, or server
Files:
hosts/server/nixcloud/home-assistant/dashboard.nixhosts/server/nixcloud/home-assistant/default.nixhosts/server/nixcloud/home-assistant/dashboard/views/security.nixhosts/server/nixcloud/home-assistant/dashboard/views/server.nixhosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nixhosts/server/nixcloud/home-assistant/dashboard/views/energy.nixhosts/server/nixcloud/home-assistant/music.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/dashboard/components/templates/popup.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/media-player.nixhosts/server/nixcloud/home-assistant/dashboard/components/navbar.nixhosts/server/nixcloud/home-assistant/static.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nixhosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nixhosts/server/nixcloud/home-assistant/automations/bedroom_ac_adaptive_fan_speed.yamlhosts/server/nixcloud/home-assistant/dashboard/components/button-cards.nixhosts/server/nixcloud/home-assistant/dashboard/views/music.nixhosts/server/nixcloud/home-assistant/dashboard/lib.nix
🧠 Learnings (28)
📚 Learning: 2026-03-01T12:27:25.837Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/test.md:0-0
Timestamp: 2026-03-01T12:27:25.837Z
Learning: For changes affecting only hosts, build at least one affected host configuration using 'nix build .#nixosConfigurations.<hostname>.config.system.build.toplevel'
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard.nix
📚 Learning: 2026-03-01T12:27:25.837Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/test.md:0-0
Timestamp: 2026-03-01T12:27:25.837Z
Learning: For changes affecting only homes, build at least one affected home configuration using 'nix build .#homeConfigurations.<user>@<host>.activationPackage'
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard.nixhosts/server/nixcloud/home-assistant/default.nixhosts/server/nixcloud/home-assistant/static.nix
📚 Learning: 2026-03-01T12:24:29.910Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/contributing/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:29.910Z
Learning: Applies to home/**/*.nix : Test at least one affected home configuration before submitting changes
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard.nixhosts/server/nixcloud/home-assistant/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:24:22.881Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/code-style/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:22.881Z
Learning: Applies to **/*.nix : Prefer minimal comments; code should be self-explanatory, using comments to explain *why*, not *what*
Applied to files:
hosts/server/nixcloud/home-assistant/default.nix
📚 Learning: 2026-03-01T12:24:22.881Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/code-style/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:22.881Z
Learning: Applies to **/*.nix : Use `let` bindings with `inherit` for importing functions from libraries (e.g., `inherit (lib) mkIf mkEnableOption`)
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/views/security.nixhosts/server/nixcloud/home-assistant/dashboard/views/server.nixhosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nixhosts/server/nixcloud/home-assistant/dashboard/views/energy.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/dashboard/components/templates/popup.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nixhosts/server/nixcloud/home-assistant/dashboard/views/music.nix
📚 Learning: 2026-03-01T12:27:02.914Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/nix-review.md:0-0
Timestamp: 2026-03-01T12:27:02.914Z
Learning: Applies to **/*.nix : Follow the standard NixOS module structure pattern with config, lib, pkgs parameters and proper `let`/`in` blocks
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/views/server.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nix
📚 Learning: 2026-03-01T12:24:22.881Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/code-style/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:22.881Z
Learning: Applies to **/*.nix : Follow the standard module structure pattern with `config`, `lib`, `pkgs` destructuring, `let` bindings for module configuration, and `options`/`config` sections
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/views/server.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nix
📚 Learning: 2026-03-01T12:26:14.740Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/project-structure/SKILL.md:0-0
Timestamp: 2026-03-01T12:26:14.740Z
Learning: Applies to modules/home-manager/default.nix : Home-Manager modules should be exported through `modules/home-manager/default.nix`
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nixhosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nixhosts/server/nixcloud/home-assistant/static.nix
📚 Learning: 2026-03-01T12:25:06.603Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/modules/SKILL.md:0-0
Timestamp: 2026-03-01T12:25:06.603Z
Learning: Applies to modules/nixos/default.nix : Export module categories from top-level `modules/nixos/default.nix` as attribute set with structure: `{ boot = import ./boot; hardware = import ./hardware; services = import ./services; }`
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nix
📚 Learning: 2026-03-01T12:27:02.914Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/nix-review.md:0-0
Timestamp: 2026-03-01T12:27:02.914Z
Learning: Applies to **/*.nix : Use camelCase for attributes (e.g., `myOption`, `enableFeature`, `services.myService.enable`)
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nix
📚 Learning: 2026-03-01T12:27:02.914Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/nix-review.md:0-0
Timestamp: 2026-03-01T12:27:02.914Z
Learning: Applies to **/*.nix : Avoid inline JSON/YAML strings; use `builtins.toJSON` for structured data
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nix
📚 Learning: 2026-03-01T12:27:02.914Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/nix-review.md:0-0
Timestamp: 2026-03-01T12:27:02.914Z
Learning: Applies to **/*.nix : When generating JSON/YAML, define as Nix attribute sets and convert using `builtins.toJSON` instead of inline strings
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nix
📚 Learning: 2026-03-01T12:26:14.740Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/project-structure/SKILL.md:0-0
Timestamp: 2026-03-01T12:26:14.740Z
Learning: Applies to modules/nixos/default.nix : NixOS modules should be exported through `modules/nixos/default.nix`
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:25:06.603Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/modules/SKILL.md:0-0
Timestamp: 2026-03-01T12:25:06.603Z
Learning: Applies to modules/home-manager/*/default.nix : Register Home-Manager modules in parent `default.nix` using imports list pattern
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:24:57.319Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/hosts/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:57.319Z
Learning: Applies to hosts/{server,desktop,laptop}/*/default.nix : Each host requires a `default.nix` file as the main configuration entry point
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nix
📚 Learning: 2026-03-01T12:25:06.603Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/modules/SKILL.md:0-0
Timestamp: 2026-03-01T12:25:06.603Z
Learning: Applies to modules/nixos/*/default.nix : Register NixOS modules in parent `default.nix` using imports list pattern: `_: { imports = [ ./module-a.nix ./module-b.nix ]; }`
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:24:57.319Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/hosts/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:57.319Z
Learning: Applies to hosts/{desktop,laptop}/*/hardware.nix : Physical hardware configurations should import appropriate modules from `inputs.nixos-hardware` (e.g., CPU, SSD, GPU modules) in `hardware.nix`
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:24:22.881Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/code-style/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:22.881Z
Learning: Applies to **/*.nix : Prefer relative imports over absolute imports (e.g., `./modules/foo.nix`)
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:27:02.914Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/nix-review.md:0-0
Timestamp: 2026-03-01T12:27:02.914Z
Learning: Applies to **/*.nix : Group imports at the top of the file and use list format for multiple imports
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nix
📚 Learning: 2026-03-01T12:27:02.914Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/nix-review.md:0-0
Timestamp: 2026-03-01T12:27:02.914Z
Learning: Applies to **/*.nix : Prefer relative imports (e.g., `./modules/foo.nix`) over absolute paths
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:27:02.914Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/agent/nix-review.md:0-0
Timestamp: 2026-03-01T12:27:02.914Z
Learning: Applies to **/*.nix : Ensure all used functions are properly inherited to avoid circular imports and hidden dependencies
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nix
📚 Learning: 2026-03-01T12:24:22.881Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/code-style/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:22.881Z
Learning: Applies to **/*.nix : Group imports at the top of the Nix file and use list format for multiple imports
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nix
📚 Learning: 2026-03-01T12:26:01.611Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/packages/SKILL.md:0-0
Timestamp: 2026-03-01T12:26:01.611Z
Learning: Applies to overlays/default.nix : Expose custom packages via overlays/default.nix by importing the pkgs directory with inputs, lib, and pkgs parameters
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/components/button-cards/default.nixhosts/server/nixcloud/home-assistant/dashboard/components/templates/popup.nixhosts/server/nixcloud/home-assistant/dashboard/views/home.nix
📚 Learning: 2026-03-01T12:26:41.504Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/users/SKILL.md:0-0
Timestamp: 2026-03-01T12:26:41.504Z
Learning: Applies to home/*/hm-config.nix : Import shared user configurations from `home/shared/` directories in user configs: use `../shared/global/` for configs applied to all users, `../shared/applications/` for application configs, `../shared/desktop/` for desktop environment configs, and `../shared/features/cli/` for CLI tool configurations
Applied to files:
hosts/server/nixcloud/home-assistant/dashboard/default.nix
📚 Learning: 2026-03-01T12:24:57.319Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/hosts/SKILL.md:0-0
Timestamp: 2026-03-01T12:24:57.319Z
Learning: Applies to home/*/**.nix : Create `home/<username>/<hostname>.nix` files to assign users to hosts, which enables auto-detection and inclusion of the user's home-manager configuration
Applied to files:
hosts/server/nixcloud/home-assistant/static.nix
📚 Learning: 2026-03-01T12:26:41.504Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/users/SKILL.md:0-0
Timestamp: 2026-03-01T12:26:41.504Z
Learning: Applies to home/*/hm-config.nix : Create `hm-config.nix` in `home/<username>/` as the main Home-Manager entry point containing shared configuration across all hosts for that user
Applied to files:
hosts/server/nixcloud/home-assistant/static.nix
📚 Learning: 2026-03-01T12:26:41.504Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/users/SKILL.md:0-0
Timestamp: 2026-03-01T12:26:41.504Z
Learning: Applies to home/*/ : User directory structure must follow the pattern `home/<username>/` with required files: `hm-config.nix` (main Home-Manager entry point) and `id_ed25519.pub` (SSH public key), plus optional files: `os-config.nix`, `secrets.yaml`, host-specific `<hostname>.nix`, and `features/` directory
Applied to files:
hosts/server/nixcloud/home-assistant/static.nix
📚 Learning: 2026-03-01T12:25:06.603Z
Learnt from: CR
Repo: DaRacci/nix-config PR: 0
File: .opencode/skills/modules/SKILL.md:0-0
Timestamp: 2026-03-01T12:25:06.603Z
Learning: Applies to modules/home-manager/**/*.nix : Use `user.<name>` namespace for user-specific options in Home-Manager modules
Applied to files:
hosts/server/nixcloud/home-assistant/static.nix
🔇 Additional comments (8)
hosts/server/nixcloud/home-assistant/default.nix (1)
46-60: Commented-out packages acknowledged.These packages are commented out, which is fine for the refactoring work in progress. Consider adding a brief comment explaining why they're disabled (e.g., "temporarily disabled pending X") or removing them entirely if no longer needed.
hosts/server/nixcloud/home-assistant/dashboard/views/security.nix (1)
10-10: Correct update to passlibto navbar component.This change properly aligns with the updated
navbar.nixmodule signature that now requireslibto access shared dashboard data.hosts/server/nixcloud/home-assistant/dashboard/views/server.nix (1)
4-4: Correct update to passlibto navbar component.This change properly aligns with the updated
navbar.nixmodule signature, consistent with the same change insecurity.nix.hosts/server/nixcloud/home-assistant/dashboard/kiosk-mode.nix (1)
1-20: LGTM!The module correctly imports the shared library and uses dynamic entity references. The attribute interpolation
entity.${entities.inputBooleans.debugRounded}will correctly expand toentity."input_boolean.debug_rounded", matching the expected Home Assistant configuration structure.hosts/server/nixcloud/home-assistant/dashboard/views/music.nix (3)
4-7: Good refactor to use centralized library imports.The change to import
dashLiband usewith dashLibis cleaner than the previous inline import pattern. This properly exposes all helper functions and entity references.
136-177: Clean refactor using helper functions.The migration from inline button definitions to
mkMusicRoomTransferButtonreduces duplication and improves maintainability. The helper function signature matches the context snippet fromlib.nix.
195-215: Good use ofmkMusicSwipeCardwith optionalconditionEntity.The Bedroom card correctly uses
conditionEntity = mediaPlayers.rooms.bedroom_nestto check a different entity's state than the one being controlled, which matches the helper function's design.hosts/server/nixcloud/home-assistant/dashboard/lib.nix (1)
3-4: No action required. The importinherit (lib.mine.strings) toSnakeCase;is valid. The function is defined inlib/strings.nixat line 60 and is actively used throughout the codebase in multiple locations.
| - id: bedroom_ac_adaptive_fan_speed | ||
| alias: Bedroom AC - Adaptive Fan Speed | ||
| description: > | ||
| Automatically adjusts bedroom AC fan speed based on how quickly the room's | ||
| temperature distance to target is shrinking. | ||
| mode: single |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for definitions of the required helper entities in the repository
echo "=== Searching for input_datetime.bedroom_ac_fan_last_adjusted ==="
rg -n "bedroom_ac_fan_last_adjusted" --type yaml --type nix
echo "=== Searching for input_number.target_temperature ==="
rg -n "target_temperature" --type yaml --type nix
echo "=== Searching for bedroom_ac_distance_change sensors ==="
rg -n "bedroom_ac_distance_change" --type yaml --type nixRepository: DaRacci/nix-config
Length of output: 1493
🏁 Script executed:
# Check the directory structure and list files in the home-assistant configuration
find hosts/server/nixcloud/home-assistant -type f -name "*.yaml" -o -name "*.yml" | head -20Repository: DaRacci/nix-config
Length of output: 195
🏁 Script executed:
# Search more broadly for helper entity definitions
# Look for 'input_datetime' or 'input_number' definitions (not just references)
rg -n "input_datetime|input_number" --type yaml | grep -E "(input_datetime|input_number):" | head -20Repository: DaRacci/nix-config
Length of output: 44
🏁 Script executed:
# Check if there's a helpers.yaml or automations index file
find hosts/server/nixcloud -type f \( -name "*helper*" -o -name "*input*" \)Repository: DaRacci/nix-config
Length of output: 44
🏁 Script executed:
# Verify the repository structure matches the guideline
# Check if the file path follows the pattern: hosts/server/<hostname>/
ls -la hosts/server/ 2>/dev/null || echo "hosts/server/ not found"Repository: DaRacci/nix-config
Length of output: 694
Automation depends on several helper entities that must be defined separately.
This automation references helper entities that are not defined in the repository:
input_datetime.bedroom_ac_fan_last_adjusted(cooldown tracking)input_number.target_temperature(target temperature setting)sensor.bedroom_ac_distance_change_5m,sensor.bedroom_ac_distance_change_10m,sensor.bedroom_ac_distance_change_15m(statistics sensors)
Ensure these entities are configured in Home Assistant or the automation will fail silently with default/zero values.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@hosts/server/nixcloud/home-assistant/automations/bedroom_ac_adaptive_fan_speed.yaml`
around lines 1 - 6, The automation references missing helper entities so it will
behave incorrectly; add and configure the required helpers: create an
input_datetime named input_datetime.bedroom_ac_fan_last_adjusted for cooldown
tracking, create an input_number named input_number.target_temperature with
appropriate min/max/step and units for the desired target, and define the three
sensors sensor.bedroom_ac_distance_change_5m,
sensor.bedroom_ac_distance_change_10m, and sensor.bedroom_ac_distance_change_15m
(e.g. as template or statistics sensors) so they report the distance-change
values used by the automation; ensure each entity ID exactly matches the names
used in the automation and set sensible initial values/units to avoid
zero/default behavior.
| selected_change_sensor: > | ||
| {% if (window_minutes | int) == 5 %} | ||
| sensor.bedroom_ac_distance_change_5m | ||
| {% elif (window_minutes | int) == 10 %} | ||
| sensor.bedroom_ac_distance_change_10m | ||
| {% else %} | ||
| sensor.bedroom_ac_distance_change_15m | ||
| {% endif %} | ||
|
|
||
| # Statistics change sensor is newest - oldest. | ||
| # If distance to target is reducing, this value is negative. | ||
| distance_change: "{{ states(selected_change_sensor) | float(0) }}" | ||
| distance_reduced_by: "{{ (0 - distance_change) | float(0) }}" |
There was a problem hiding this comment.
Potential division by zero when calculating progress bar percentage.
In the distance_change calculation on line 65-66, if the statistics sensor returns an unexpected value or the sensor is unavailable, the float conversion defaults to 0. While this won't cause a runtime error, it may lead to unexpected fan adjustments. Consider adding a condition to skip adjustment when distance_change is 0 (no data).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@hosts/server/nixcloud/home-assistant/automations/bedroom_ac_adaptive_fan_speed.yaml`
around lines 54 - 66, The template for selected_change_sensor/distance_change
may yield 0 when the sensor is missing or returns non-numeric, leading to
spurious fan adjustments; update the template logic around
selected_change_sensor, distance_change, and distance_reduced_by to first detect
unavailable/unknown states (or non-numeric values) and short-circuit the
automation (skip adjustment) when distance_change is zero or not a valid number;
specifically, add a guard check that ensures selected_change_sensor's state is
numeric and non-zero before computing distance_reduced_by or proceeding with
fan-speed calculations in the automation that uses distance_change and
distance_reduced_by.
| lovelace = { | ||
| mode = "yaml"; | ||
| resource_mode = "yaml"; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check the NixOS Home Assistant module for valid lovelace options
echo "=== Searching for lovelace mode options in nixpkgs ==="
ast-grep --pattern 'lovelace = {
$$$
}'
echo "=== Searching for resource_mode in the codebase ==="
rg -n "resource_mode" --type nix
echo "=== Checking Home Assistant module definition ==="
rg -n "lovelace\s*=" --type nix -C 5Repository: DaRacci/nix-config
Length of output: 1143
🌐 Web query:
What are the valid options for Home Assistant Lovelace configuration in NixOS services.home-assistant.config.lovelace?
💡 Result:
The valid options for services.home-assistant.config.lovelace in the NixOS Home Assistant module correspond to the lovelace: section in Home Assistant's configuration.yaml. This is a submodule allowing declarative configuration of Lovelace dashboard settings. Key documented options include: - mode: Enum with values "yaml" or "storage" (default: "storage", auto-set to "yaml" if lovelaceConfig or lovelaceConfigFile is used). Determines if Lovelace uses YAML files or UI-managed storage. The submodule supports additional standard Lovelace configuration options (e.g., resources, dashboards, themes), as it is an open YAML submodule mirroring Home Assistant's structure. For full details, refer to Home Assistant docs: https://www.home-assistant.io/lovelace/dashboards/. Related top-level options impacting Lovelace: - services.home-assistant.lovelaceConfig: Nix attrset for ui-lovelace.yaml (YAML mode). - services.home-assistant.customLovelaceModules: List of custom Lovelace card packages, auto-added as resources. - services.home-assistant.lovelaceConfigFile: Path to external ui-lovelace.yaml. Example: services.home-assistant.config = { lovelace = { mode = "yaml"; # resources = [ ... ]; }; };
Citations:
- 1: https://search.nixos.org/options?channel=unstable&from=0&query=services.home-assistant.config&size=50&sort=relevance&type=packages
- 2: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/home-automation/home-assistant.nix
- 3: https://mynixos.com/nixpkgs/option/services.home-assistant.config
Change resource_mode to mode.
The Home Assistant Lovelace configuration uses mode (not resource_mode) to specify the dashboard configuration type. Valid values are "yaml" or "storage". Update line 153 to use the correct option name.
Diff
lovelace = {
- resource_mode = "yaml";
+ mode = "yaml";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/dashboard.nix` around lines 152 - 153,
The lovelace dashboard block uses the wrong option name: change the property
named resource_mode to mode so the Lovelace config uses the correct key
(lovelace -> mode) and set its value to "yaml" or "storage" as intended; update
any references to resource_mode inside the lovelace block to use mode so Home
Assistant recognizes the dashboard configuration.
| name = "Monitored"; | ||
| label = "[[[return states[\"sensor.uptimekuma_uptime_racci_dev\"].attributes.monitored]]]"; | ||
| label = "[[[return states[\"${entities.sensors.uptimekuma}\"].attributes.monitored]]]"; | ||
| template = "nav_button_state_small"; |
There was a problem hiding this comment.
Template nav_button_state_small may be missing from button_card_templates.
This card references template = "nav_button_state_small" (line 42) and template = "nav_button_small" (line 61), but the current button-cards/default.nix only exports media-player. These templates need to be added to the button-cards export.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/dashboard/components/admin-panel.nix` at
line 42, The dashboard admin-panel references templates "nav_button_state_small"
and "nav_button_small" but button-cards/default.nix currently only exports
"media-player"; update button-cards/default.nix to export both
"nav_button_state_small" and "nav_button_small" (and ensure their template
definitions exist in the button card templates file), so the templates used by
admin-panel.nix are available at import time.
| { lib, ... }: | ||
| with (import ../lib.nix { inherit lib; }); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider using let bindings with inherit instead of with for clearer dependencies.
While many functions from lib.nix are used throughout this file, the with statement at module level hides which dependencies are actually used. As per coding guidelines, prefer explicit inherit to make dependencies visible.
♻️ Suggested approach
{ lib, ... }:
-with (import ../lib.nix { inherit lib; });
+let
+ dashLib = import ../lib.nix { inherit lib; };
+ inherit (dashLib) mkStyles colourOnOff style jsMatch entities mediaPlayers template;
+in
{As per coding guidelines: "Use let bindings with inherit for importing functions from libraries" and "Avoid using with at module level as it pollutes scope and hides dependencies".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/dashboard/components/button-cards.nix`
around lines 1 - 2, The top-level use of "with (import ../lib.nix { inherit lib;
});" hides which functions from lib are used; replace this module-level
with-binding by creating a let block that imports ../lib.nix and explicitly
inherits only the symbols you use (e.g., let libPkg = import ../lib.nix {
inherit lib; }; in { inherit (libPkg) <list-of-functions>; } ), remove the
with(...) wrapper, and update all references to use the inherited names; ensure
you list the actual functions/constants you consume from lib so dependencies are
explicit.
|
|
||
| # (mkGridSection) | ||
|
|
||
| # Popups | ||
| (mkGridSection { | ||
| cards = [ | ||
| (mkVerticalStack { | ||
| cards = [ | ||
| (mkBubbleCard { | ||
| name = "Bedroom"; | ||
| icon = "mdi:bed-king-outline"; | ||
| cardType = "pop-up"; | ||
| hash = "#bedroom"; | ||
| }) | ||
|
|
||
| (mkMushroomChipsCard { | ||
| chips = [ | ||
| (mkEntity { | ||
| entity = "binary_sensor.bedroom_presence_sensor"; | ||
| contentInfo = "last-changed"; | ||
| icon = "mdi:motion-sensor"; | ||
| iconColor = "yellow"; | ||
| }) | ||
| (mkEntity { | ||
| entity = "binary_sensor.bedroom_window_sensor"; | ||
| icon = "mdi:window-closed-variant"; | ||
| iconColor = "red"; | ||
| }) | ||
| (mkEntity { | ||
| entity = "binary_sensor.bedroom_door_sensor"; | ||
| icon = "mdi:door-closed"; | ||
| iconColor = "blue"; | ||
| }) | ||
| ]; | ||
| }) | ||
|
|
||
| (mkHeading { | ||
| heading = "Climate"; | ||
| heading_style = "title"; | ||
| icon = "mdi:thermostat"; | ||
| badges = [ | ||
| (mkEntity { | ||
| entity = "climate.bedroom_ac"; | ||
| stateContent = "current_temperature"; | ||
| color = "red"; | ||
| showIcon = true; | ||
| showState = true; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| (mkEntity { | ||
| entity = "climate.bedroom_ac"; | ||
| stateContent = "current_humidity"; | ||
| color = "blue"; | ||
| showIcon = true; | ||
| showState = true; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| ]; | ||
| }) | ||
| (mkBubbleCard { | ||
| cardType = "climate"; | ||
| entity = "climate.bedroom_ac"; | ||
| showState = true; | ||
| subButton = [ | ||
| { | ||
| name = "HVAC modes menu"; | ||
| select_attribute = "hvac_modes"; | ||
| state_background = false; | ||
| show_arrow = false; | ||
| } | ||
| ]; | ||
| }) | ||
|
|
||
| (mkHeading { | ||
| heading = "Devices"; | ||
| heading_style = "title"; | ||
| icon = "mdi:devices"; | ||
| badges = [ | ||
| (mkEntity { | ||
| entity = "input_boolean.bedroom_occupancy"; | ||
| icon = "mdi:light-switch"; | ||
| color = "red"; | ||
| showState = false; | ||
| showIcon = true; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| (mkEntity { | ||
| entity = "input_boolean.bedroom_night_mode"; | ||
| showState = false; | ||
| showIcon = true; | ||
| color = "blue"; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| ]; | ||
| }) | ||
|
|
||
| (mkGridSection { | ||
| columns = 3; | ||
| cards = [ | ||
| (mkButtonCard { | ||
| entity = "binary_sensor.is_alarm_on"; | ||
| name = "Alarm"; | ||
| label = template.getState "sensor.wake_time_1"; | ||
| template = "nav_button_small"; | ||
| variables = { | ||
| navigationPath = "home#alarm"; | ||
| iconOn = "mdi:alarm"; | ||
| iconOff = "mdi:alarm-off"; | ||
| backgroundColorOn = jsColours.yellow; | ||
| backgroundColorOff = jsColours.contrast2; | ||
| colorOn = jsColours.black; | ||
| colorOff = jsColours.contrast20; | ||
| }; | ||
| }) | ||
| (mkConditional { | ||
| conditions = [ | ||
| (condState { | ||
| entity = "alarm_control_panel.security_system"; | ||
| state = "armed_night"; | ||
| }) | ||
| ]; | ||
| card = mkButtonCard { | ||
| entity = "input_boolean.waking_up"; | ||
| name = "Waking Up"; | ||
| label = template.getState "input_boolean.waking_up"; | ||
| showLabel = true; | ||
| tapAction = mkAction { | ||
| action = "toggle"; | ||
| haptic = "success"; | ||
| }; | ||
| template = "button_template"; | ||
| variables = { | ||
| icon2 = "mdi:weather-sunset-up"; | ||
| backgroundColorOff = jsColours.contrast2; | ||
| backgroundColorOn = jsColours.orange; | ||
| colorOn = jsColours.black; | ||
| colorOff = jsColours.contrast20; | ||
| }; | ||
| }; | ||
| }) | ||
| (mkConditional { | ||
| conditions = [ | ||
| (condState { | ||
| entity = "alarm_control_panel.security_system"; | ||
| state = "armed_night"; | ||
| }) | ||
| ]; | ||
| card = mkButtonCard { | ||
| entity = "input_boolean.going_to_bed"; | ||
| name = "Waking Up"; | ||
| label = template.getState "input_boolean.going_to_bed"; | ||
| showLabel = true; | ||
| tapAction = mkAction { | ||
| action = "toggle"; | ||
| haptic = "success"; | ||
| }; | ||
| template = "button_template"; | ||
| variables = { | ||
| icon2 = "mdi:bed"; | ||
| backgroundColorOff = jsColours.contrast2; | ||
| backgroundColorOn = jsColours.blue; | ||
| colorOn = jsColours.black; | ||
| colorOff = jsColours.contrast20; | ||
| }; | ||
| }; | ||
| }) | ||
| ]; | ||
| }) | ||
|
|
||
| (mkGridSection { | ||
| columns = 1; | ||
| cards = [ | ||
| (mkHeading { | ||
| heading = "Lights"; | ||
| heading_style = "subtitle"; | ||
| icon = "mdi:lightbulb-group"; | ||
| badges = [ | ||
| (mkEntity { | ||
| entity = "light.bedroom_lights"; | ||
| showIcon = true; | ||
| showState = false; | ||
| color = "yellow"; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| (mkEntity { | ||
| entity = "switch.adaptive_lighting_bedroom"; | ||
| showIcon = true; | ||
| showState = false; | ||
| color = "orange"; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| (mkEntity { | ||
| entity = "switch.adaptive_lighting_adapt_color_bedroom"; | ||
| showIcon = true; | ||
| showState = false; | ||
| color = "pink"; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| (mkEntity { | ||
| entity = "switch.adaptive_lighting_adapt_brightness_bedroom"; | ||
| showIcon = true; | ||
| showState = false; | ||
| color = "yellow"; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| (mkEntity { | ||
| entity = "switch.adaptive_lighting_sleep_mode_bedroom"; | ||
| showIcon = true; | ||
| showState = false; | ||
| color = "blue"; | ||
| tapAction = mkAction { action = "toggle"; }; | ||
| }) | ||
| ]; | ||
| }) | ||
|
|
||
| (mkGridSection { | ||
| columns = 1; | ||
| cards = [ | ||
| (mkButtonCard { | ||
| name = "Top Light"; | ||
| entity = "lighting.bedroom_light"; | ||
| template = "light_rgb"; | ||
| }) | ||
| ]; | ||
| }) | ||
| ]; | ||
| }) | ||
|
|
||
| (mkHeading { | ||
| heading = "Media"; | ||
| heading_style = "title"; | ||
| icon = "mdi:music"; | ||
| }) | ||
| (mkSwipeCard { | ||
| cardWidth = "calc(100% - 48px)"; | ||
| parameters = { | ||
| centeredSlides = true; | ||
| slidesPerView = "auto"; | ||
| spaceBetween = 16; | ||
| initialSlide = 0; | ||
| }; | ||
| cards = [ | ||
| (mkConditional { | ||
| conditions = [ | ||
| (condState { | ||
| entity = "media_player.bedroom_speakers"; | ||
| state_not = "standby"; | ||
| }) | ||
| (condState { | ||
| entity = "media_player.bedroom_speakers"; | ||
| state_not = "off"; | ||
| }) | ||
| ]; | ||
| card = mkButtonCard { | ||
| entity = "media_player.bedroom_speakers"; | ||
| template = "custom_card_mediaplayer_music"; | ||
| }; | ||
| }) | ||
|
|
||
| (mkConditional { | ||
| conditions = [ | ||
| (condState { | ||
| entity = "sensor.bedroom_next_timer"; | ||
| state_not = "unknown"; | ||
| }) | ||
| (condState { | ||
| entity = "sensor.bedroom_next_timer"; | ||
| state_not = "unavailable"; | ||
| }) | ||
| ]; | ||
| card = mkButtonCard { | ||
| entity = "sensor.bedroom_next_timer"; | ||
| name = "Bedroom Timer"; | ||
| icon = "mdi:timer-outline"; | ||
| showName = true; | ||
| showIcon = true; | ||
| showLabel = false; | ||
| showState = false; | ||
| tapAction = mkAction { | ||
| action = "more-info"; | ||
| }; | ||
| holdAction = mkAction { | ||
| action = "navigate"; | ||
| }; | ||
| customFields = { | ||
| bar = '' | ||
| [[[ | ||
| var color = "var(--green)"; | ||
| var state = 100 - states['sensor.bed_room_timer'].attributes.remaining_perc; | ||
| if (state < 10) color = "var(--red)"; | ||
| else if (state < 50) color = "var(--yellow)"; | ||
| else if (state < 90) color = "var(--orange)"; | ||
| return ` | ||
| <div> | ||
| <div style="background:''${color}; height: 12px; width:''${state}%"> | ||
| </div> | ||
| </div>` | ||
| ]]] | ||
| ''; | ||
| rem.card = mkConditional { | ||
| conditions = [ | ||
| (condState { | ||
| entity = "sensor.bedroom_next_timer"; | ||
| state_not = "unknown"; | ||
| }) | ||
| ]; | ||
| card = mkButtonCard { | ||
| entity = "sensor.bedroom_next_timer"; | ||
| name = template.remainingTime; | ||
| showIcon = false; | ||
| styles = mkStyles { | ||
| card = { | ||
| width = "min"; | ||
| background = "none"; | ||
| overflow = "visible"; | ||
| }; | ||
| name = { | ||
| font-size = "14px"; | ||
| margin-top = "6px"; | ||
| font-weight = 600; | ||
| color = jsColours.contrast20; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| icon1 = template.returnIcon "mdi:bed-king-outline"; | ||
| }; | ||
| styles = mkStyles { | ||
| grid = { | ||
| grid-template-areas = "\"rem icon1\" \"n icon2\" \"bar bar\""; | ||
| grid-template-rows = "24px 1fr 24px min-content min-content min-content"; | ||
| grid-template-columns = "60% 40%"; | ||
| }; | ||
| card = { | ||
| height = "100%"; | ||
| padding = "1rem"; | ||
| background = jsColours.contrast2; | ||
| }; | ||
| img_cell = { | ||
| position = "absolute"; | ||
| top = "20%"; | ||
| left = "40%"; | ||
| overflow = "visible"; | ||
| }; | ||
| icon = { | ||
| position = "absolute"; | ||
| width = "20em"; | ||
| opacity = "20%"; | ||
| color = jsColours.contrast20; | ||
| transform = "rotate(-20deg)"; | ||
| }; | ||
| label = { | ||
| text-align = "left"; | ||
| font-size = "18px"; | ||
| font-weight = 500; | ||
| justify-self = "start"; | ||
| align-self = "end"; | ||
| overflow = "visible"; | ||
| color = jsColours.contrast20; | ||
| }; | ||
| name = { | ||
| text-align = "left"; | ||
| font-size = "12px"; | ||
| justify-self = "start"; | ||
| align-self = "center"; | ||
| overflow = "visible"; | ||
| color = jsColours.contrast20; | ||
| }; | ||
| custom_fields = { | ||
| bar = { | ||
| justify-self = "start"; | ||
| width = "100%"; | ||
| height = template.stateIfElse { | ||
| entity = "entity.state"; | ||
| states = [ "unknown" ]; | ||
| ifTrue = "0px"; | ||
| ifFalse = "12px"; | ||
| }; | ||
| }; | ||
| rem = { | ||
| justify-self = "start"; | ||
| font-size = "14px"; | ||
| font-weight = 600; | ||
| align-self = "end"; | ||
| height = template.stateIfElse { | ||
| entity = "entity.state"; | ||
| states = [ "unknown" ]; | ||
| ifTrue = "0px"; | ||
| ifFalse = "27px"; | ||
| }; | ||
| }; | ||
| }; | ||
| icon1 = { | ||
| justify-self = "end"; | ||
| width = "24px"; | ||
| color = jsColours.contrast20; | ||
| }; | ||
| }; | ||
| }; | ||
| }) | ||
| ]; | ||
| }) | ||
| ]; | ||
| }) | ||
| ]; | ||
| grid_options = { | ||
| column_span = 3; | ||
| }; | ||
| }) |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Many hardcoded entity IDs inconsistent with centralisation goal.
The Bedroom popup section introduces numerous hardcoded entity references (e.g., binary_sensor.bedroom_presence_sensor, climate.bedroom_ac, input_boolean.bedroom_occupancy). Consider adding these to lib.nix entities for consistency with the refactor's centralisation pattern.
This aligns with the PR description noting "many hardcoded IDs" as a known issue.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/dashboard/views/home.nix` around lines
27 - 435, Replace the hardcoded entity IDs used in the Bedroom popup (examples:
binary_sensor.bedroom_presence_sensor, binary_sensor.bedroom_window_sensor,
binary_sensor.bedroom_door_sensor, climate.bedroom_ac,
input_boolean.bedroom_occupancy, input_boolean.bedroom_night_mode,
media_player.bedroom_speakers, sensor.bedroom_next_timer,
lighting.bedroom_light, and related switches) with centralized references
defined in lib.nix (e.g., entities.bedroom.<name>) and update usages in the
mkBubbleCard, mkEntity, mkHeading badges, mkButtonCard templates, mkConditional
condState blocks, mkSwipeCard custom_fields, and template.getState calls so they
pull from the new entity constants instead of literal strings; add the
corresponding entries to lib.nix (following the existing entities structure) and
ensure template.returnIcon/template.remainingTime usages continue to work with
the new references.
| card = mkButtonCard { | ||
| entity = "input_boolean.going_to_bed"; | ||
| name = "Waking Up"; | ||
| label = template.getState "input_boolean.going_to_bed"; |
There was a problem hiding this comment.
Incorrect button name: "Waking Up" should be "Going to Bed".
The button entity is input_boolean.going_to_bed but the name is set to "Waking Up" (copy-paste error from the previous conditional block).
Suggested fix
card = mkButtonCard {
entity = "input_boolean.going_to_bed";
- name = "Waking Up";
+ name = "Going to Bed";
label = template.getState "input_boolean.going_to_bed";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| card = mkButtonCard { | |
| entity = "input_boolean.going_to_bed"; | |
| name = "Waking Up"; | |
| label = template.getState "input_boolean.going_to_bed"; | |
| card = mkButtonCard { | |
| entity = "input_boolean.going_to_bed"; | |
| name = "Going to Bed"; | |
| label = template.getState "input_boolean.going_to_bed"; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/dashboard/views/home.nix` around lines
174 - 177, The card for mkButtonCard referencing entity
"input_boolean.going_to_bed" has an incorrect name "Waking Up"; update the name
property in that mkButtonCard block to "Going to Bed" so the label matches the
entity (look for the mkButtonCard block where entity =
"input_boolean.going_to_bed" and change its name value).
| (mkButtonCard { | ||
| name = "Top Light"; | ||
| entity = "lighting.bedroom_light"; | ||
| template = "light_rgb"; | ||
| }) |
There was a problem hiding this comment.
Likely typo: lighting.bedroom_light should be light.bedroom_light.
Home Assistant uses the light. domain prefix, not lighting.. This will cause the entity to not be found.
Suggested fix
(mkButtonCard {
name = "Top Light";
- entity = "lighting.bedroom_light";
+ entity = "light.bedroom_light";
template = "light_rgb";
})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| (mkButtonCard { | |
| name = "Top Light"; | |
| entity = "lighting.bedroom_light"; | |
| template = "light_rgb"; | |
| }) | |
| (mkButtonCard { | |
| name = "Top Light"; | |
| entity = "light.bedroom_light"; | |
| template = "light_rgb"; | |
| }) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/dashboard/views/home.nix` around lines
245 - 249, The entity string in the mkButtonCard for "Top Light" is using the
wrong domain prefix; update the entity value in the mkButtonCard block (the card
with name "Top Light" and template "light_rgb") from "lighting.bedroom_light" to
"light.bedroom_light" so Home Assistant can resolve the entity.
| bar = '' | ||
| [[[ | ||
| var color = "var(--green)"; | ||
| var state = 100 - states['sensor.bed_room_timer'].attributes.remaining_perc; | ||
| if (state < 10) color = "var(--red)"; |
There was a problem hiding this comment.
Entity name mismatch: sensor.bed_room_timer vs sensor.bedroom_next_timer.
Line 315 references states['sensor.bed_room_timer'] but the card entity (line 298) and conditions use sensor.bedroom_next_timer. This will cause the progress bar calculation to fail.
Suggested fix
customFields = {
bar = ''
[[[
var color = "var(--green)";
- var state = 100 - states['sensor.bed_room_timer'].attributes.remaining_perc;
+ var state = 100 - states['sensor.bedroom_next_timer'].attributes.remaining_perc;
if (state < 10) color = "var(--red)";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| bar = '' | |
| [[[ | |
| var color = "var(--green)"; | |
| var state = 100 - states['sensor.bed_room_timer'].attributes.remaining_perc; | |
| if (state < 10) color = "var(--red)"; | |
| bar = '' | |
| [[[ | |
| var color = "var(--green)"; | |
| var state = 100 - states['sensor.bedroom_next_timer'].attributes.remaining_perc; | |
| if (state < 10) color = "var(--red)"; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/dashboard/views/home.nix` around lines
312 - 316, The progress bar JS references the wrong entity name: replace
occurrences of states['sensor.bed_room_timer'] with
states['sensor.bedroom_next_timer'] (or make the card entity match) so the
calculation in the inline script (the var state = 100 -
states['sensor.bed_room_timer'].attributes.remaining_perc line) uses the same
entity as the card (sensor.bedroom_next_timer); also scan the surrounding code
for any other mismatched uses of sensor.bed_room_timer and unify them to
sensor.bedroom_next_timer to ensure the progress calculation and conditions work
consistently.
| { | ||
| entities = { | ||
|
|
||
| }; | ||
|
|
||
| # Each user needs a profile created in Home Assistant first. | ||
| users = { | ||
| james = { | ||
| displayName = "James"; | ||
| id = "3eea636aa3de4c7f9c662ad29c6e92e0"; | ||
| }; | ||
|
|
||
| savannah = { | ||
| displayName = "Savannah"; | ||
| id = "82def695e9504f63b1eb09150073737d"; | ||
| }; | ||
| }; | ||
|
|
||
| rooms = { | ||
|
|
||
| }; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if static.nix is imported anywhere
echo "=== Files importing static.nix ==="
rg -l 'static\.nix' hosts/server/nixcloud/home-assistant/
echo ""
echo "=== Check how lib.nix defines entities ==="
head -80 hosts/server/nixcloud/home-assistant/dashboard/lib.nixRepository: DaRacci/nix-config
Length of output: 2911
🏁 Script executed:
#!/bin/bash
# Check directory structure and entry points
echo "=== Directory structure of home-assistant ==="
find hosts/server/nixcloud/home-assistant -type f -name "*.nix" | head -20
echo ""
echo "=== Check for default.nix or main entry point ==="
ls -la hosts/server/nixcloud/home-assistant/
echo ""
echo "=== Check if static.nix should be imported in any module ==="
rg -l 'home-assistant' hosts/server/nixcloud/ --type nix | head -10Repository: DaRacci/nix-config
Length of output: 3046
🏁 Script executed:
#!/bin/bash
echo "=== Content of default.nix (entry point) ==="
cat -n hosts/server/nixcloud/home-assistant/default.nix
echo ""
echo "=== Full content of static.nix ==="
cat -n hosts/server/nixcloud/home-assistant/static.nix
echo ""
echo "=== Check if static is referenced in any imports ==="
rg 'static' hosts/server/nixcloud/home-assistant/ --type nixRepository: DaRacci/nix-config
Length of output: 4156
Remove unused static.nix file or integrate it into the module structure.
This file is not imported anywhere in the configuration (notably absent from default.nix's imports list). Since it is unused, consider either removing it entirely or properly integrating it if it is intended to centralise static Home Assistant configuration. Note that user definitions here duplicate those in dashboard/lib.nix, so consolidation may be needed if this file is to be used.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@hosts/server/nixcloud/home-assistant/static.nix` around lines 3 - 23, The
file static.nix defines an unused Home Assistant static configuration (entities,
users with keys james and savannah, rooms) but is not imported anywhere; either
remove static.nix entirely or integrate it by adding it to your Nix module
imports (e.g., include it from default.nix's imports list) and consolidate
duplicate user definitions with dashboard/lib.nix (remove duplicates there or
merge into a single source of truth) so only one canonical users definition
(james, savannah) remains; update imports and references accordingly to avoid
orphaned files.
This is a pull request mirrored from Codeberg. View it here.
Originally posted by @Racci on Codeberg
Not ready for merge in the slightest atm, very broken still, most pages dont work and theres a fuck ton of hardcoded ids and shit.
This is slowly coming over from a declarative UI which i didn't even make and more or less copy pasted and cobbled to work with my entities, this is still mimicking that ones design but to actually work.
Summary by CodeRabbit
Release Notes
New Features
Improvements