Skip to content

feat: custom_sections — user-declared section blocks without forking#283

Open
TheDave94 wants to merge 2 commits into
TheRealSimon42:mainfrom
TheDave94:feat/custom-sections
Open

feat: custom_sections — user-declared section blocks without forking#283
TheDave94 wants to merge 2 commits into
TheRealSimon42:mainfrom
TheDave94:feat/custom-sections

Conversation

@TheDave94
Copy link
Copy Markdown

Summary

Adds a lightweight extension hook: `custom_sections` lets users declare their own section blocks (each with a heading + list of Lovelace cards) entirely in config, without forking the strategy.

```yaml
custom_sections:

  • key: morning_routine
    heading: "Good morning"
    icon: mdi:weather-sunrise
    cards:
    • type: markdown
      content: "{{ states('sensor.weather') }}"
    • type: tile
      entity: light.coffee_maker
      ```

The section's `key` becomes:

  • a valid entry in `sections_order` (positionable anywhere)
  • a valid value for `custom_cards.target_section` (so other custom cards can land in the new section)

Why this fits the project ethos

The project is opinionated about defaults, hackable on the surface. It already exposes:

  • `custom_cards` (inject cards into existing sections)
  • `custom_badges` (inject badges in the header)
  • `custom_views` (inject whole views in the nav)
  • `sections_order` + `section_visibility` + `hidden_section_headings` (rearrange / hide built-ins)

`custom_sections` fills the gap between "inject cards into an existing section" and "add a whole nav view" — useful for a homepage routine, a guest-mode panel, or any layout the built-in section types don't cover. Defaults don't change; users who never set `custom_sections` see no difference. This is purely an opt-in escape hatch.

Safety

  • Keys colliding with built-in `SectionKey` values are rejected (can't shadow `overview`/`areas`/etc.)
  • Duplicate keys: first one wins
  • Empty / non-array `parsed_config` → section auto-hides (returns null, no lonely heading)
  • Malformed card entries (missing `type` string) are dropped silently before render

Editor

Minimal block modeled on the existing `custom_cards` editor: per section, a `key` input, a `heading` input, an icon input, and a YAML textarea. YAML is parsed on change; errors show inline. Matches the existing UX for power-user YAML editing.

Test plan

  • Add a custom section via editor → appears at end of overview with heading + cards
  • Add the section's key to `sections_order` → appears in chosen position
  • Set `custom_cards.target_section` to a custom section key → card lands in the new section
  • Try to use `overview` as a key → rejected, section not emitted (no collision with built-in)
  • Empty YAML → section auto-hides
  • Malformed card → that card dropped, others still render

AI-drafted under human supervision by @TheDave94. Tested live on Home Assistant — fully when the relevant hardware is available, otherwise only along the code paths that don't require an actual sensor of that type.

TheDave94 (via AI) added 2 commits May 19, 2026 10:52
Power-user extension hook in the spirit of custom_cards / custom_badges /
custom_views: lets users declare their own section blocks (each with a
heading + list of Lovelace cards) entirely in config, without modifying
the strategy.

  custom_sections:
    - key: morning_routine
      heading: "Good morning"
      icon: mdi:weather-sunrise
      cards:
        - type: markdown
          content: "{{ states('sensor.weather') }}"

The section's `key` becomes:
  - a valid entry in `sections_order` (positionable anywhere)
  - a valid value for `custom_cards.target_section` (let other custom
    cards land in the new section too)

Safety:
  - keys colliding with built-in SectionKeys are rejected
  - duplicates: first one wins
  - non-array / empty parsed_config auto-hides (returns null section)
  - malformed card entries (missing string type) are dropped silently

Editor: minimal block modeled on custom_cards (key + heading + icon +
YAML textarea per section). YAML is parsed into a card array on change;
parse errors shown inline.

Doesn't change project ethos — defaults stay opinionated; this is an
explicit escape hatch for users whose use case doesn't fit the built-in
section types. No new HACS dependencies.
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -6 complexity · 0 duplication

Metric Results
Complexity -6
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

TheDave94 pushed a commit to TheDave94/oriel-dashboard that referenced this pull request May 20, 2026
Brings into main the remaining open PRs that weren't part of the prior
consolidation (bb43b04):

Improvement PRs (8 — real content):
- TheRealSimon42#277 chore(ci): translation lint guard
- TheRealSimon42#278 test: section-builder + entity-filter unit tests + snapshots
- TheRealSimon42#279 feat(rooms): auto-detect humidifier/valve/water_heater
- TheRealSimon42#280 feat(editor): derive target_section dropdown from section meta
- TheRealSimon42#281 fix(areas): auto-hide section + audit test
- TheRealSimon42#282 feat(editor): wire show_window_contacts_in_rooms + show_door_contacts_in_rooms
- TheRealSimon42#283 feat: custom_sections — user-declared sections without forking
- TheRealSimon42#284 chore(ci): release-please + release-build + ESLint enforcement

Grouped PRs (7 — content already in main via bb43b04 consolidation;
recorded with `-s ours` so the merges land in history without
duplicate/regressive edits):
- TheRealSimon42#270 grouped/optional-overview-sections
- TheRealSimon42#271 grouped/live-overview-badges
- TheRealSimon42#272 grouped/battery-view-improvements
- TheRealSimon42#273 grouped/room-view-features
- TheRealSimon42#274 grouped/section-meta-security
- TheRealSimon42#275 grouped/covers-weather
- TheRealSimon42#276 grouped/persons-overview-tweaks

CI fixes uncovered during merge:
- Bump Node 20 → 22 in validate.yml + release-build.yml (ESLint 10 requires Node 22+)
- Load eslint-plugin-security (rules off) so source-level Codacy
  disable directives resolve cleanly
- Drop unused PropertyValues import in StrategyEditor.ts

Version 1.3.4-thedave-r2 → 1.4.0-thedave (minor bump: feat: custom_sections,
auto-detect humidifier/valve, editor coverage, release automation).

Dist rebuilt + tests + ESLint pass (0 errors, 0 warnings).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@TheDave94 TheDave94 closed this May 20, 2026
@TheDave94 TheDave94 deleted the feat/custom-sections branch May 20, 2026 22:44
@TheDave94 TheDave94 restored the feat/custom-sections branch May 21, 2026 08:56
@TheDave94 TheDave94 reopened this May 21, 2026
@TheDave94
Copy link
Copy Markdown
Author

TheDave94 commented May 21, 2026

My main focus has shifted to a downstream project (Oriel Dashboard) — built on what simon42 established, taken in its own direction — but the work in this PR was always meant for simon42 and I'm happy to keep iterating on it here. Address review feedback, split bundled changes into smaller pieces, whatever helps the review. Just ping me.

TheDave94 pushed a commit to TheDave94/oriel-dashboard that referenced this pull request May 21, 2026
Brings into main the remaining open PRs that weren't part of the prior
consolidation (ee9c67c):

Improvement PRs (8 — real content):
- TheRealSimon42#277 chore(ci): translation lint guard
- TheRealSimon42#278 test: section-builder + entity-filter unit tests + snapshots
- TheRealSimon42#279 feat(rooms): auto-detect humidifier/valve/water_heater
- TheRealSimon42#280 feat(editor): derive target_section dropdown from section meta
- TheRealSimon42#281 fix(areas): auto-hide section + audit test
- TheRealSimon42#282 feat(editor): wire show_window_contacts_in_rooms + show_door_contacts_in_rooms
- TheRealSimon42#283 feat: custom_sections — user-declared sections without forking
- TheRealSimon42#284 chore(ci): release-please + release-build + ESLint enforcement

Grouped PRs (7 — content already in main via ee9c67c consolidation;
recorded with `-s ours` so the merges land in history without
duplicate/regressive edits):
- TheRealSimon42#270 grouped/optional-overview-sections
- TheRealSimon42#271 grouped/live-overview-badges
- TheRealSimon42#272 grouped/battery-view-improvements
- TheRealSimon42#273 grouped/room-view-features
- TheRealSimon42#274 grouped/section-meta-security
- TheRealSimon42#275 grouped/covers-weather
- TheRealSimon42#276 grouped/persons-overview-tweaks

CI fixes uncovered during merge:
- Bump Node 20 → 22 in validate.yml + release-build.yml (ESLint 10 requires Node 22+)
- Load eslint-plugin-security (rules off) so source-level Codacy
  disable directives resolve cleanly
- Drop unused PropertyValues import in StrategyEditor.ts

Version 1.3.4-thedave-r2 → 1.4.0-thedave (minor bump: feat: custom_sections,
auto-detect humidifier/valve, editor coverage, release automation).

Dist rebuilt + tests + ESLint pass (0 errors, 0 warnings).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@TheDave94 TheDave94 closed this May 22, 2026
@TheDave94 TheDave94 deleted the feat/custom-sections branch May 22, 2026 05:55
@TheDave94 TheDave94 restored the feat/custom-sections branch May 23, 2026 20:46
@TheDave94 TheDave94 reopened this May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant