Skip to content

Advanced editor section: version banner + debug logging #27

Description

@krissen

Motivation

The card injects its version at build time (__VERSION__ via Vite) but never
surfaces it: nothing is logged on load and there is no debug switch. Diagnosing
user reports means guessing which build is running. pollenprognos-card solves
this with an Advanced editor section (version + debug toggles) and a styled
console banner; sauna-card should match.

Proposal

Add an Advanced section to the card and badge editors, a <details> folded
by default, placed last. It holds two toggles:

  • Log version to console (show_version, default ON) — prints a styled
    %c banner with the build version once per instance on first setConfig.
  • Debug (debug, default OFF) — enables verbose console.debug logging
    across adapter detection, service calls, and graph/session computation.

The section also shows the current build version as a formatted readout
(Sauna Card version: X.Y.Z).

Because existing instances have no show_version key, the banner guard is
show_version !== false (absent ⇒ on), so old YAML keeps logging the version.

Editor UX

Folded <details class="section"> at the bottom of both editors, reusing the
existing manual-section fold styling. Two ha-formfield + ha-switch toggles
(switches reflect default-true correctly, unlike an ha-form boolean). To keep
YAML clean, only persist non-default values: store show_version: false only
when toggled off, debug: true only when toggled on. A version line renders
below the toggles.

Acceptance criteria

  • Advanced section present, folded by default, last in both card and badge editors.
  • show_version defaults ON; absent-in-YAML instances still log the banner.
  • Banner is %c-styled and printed once per instance (no spam on re-render).
  • Toggling show_version off suppresses the banner; reflected in YAML only when false.
  • debug defaults OFF; turning it on emits console.debug from instrumented paths.
  • In-editor version readout shows __VERSION__, badge variant reads "Badge".
  • Locale keys added for en/sv/fi/de.
  • Unit test for the log helper (no-op when off, banner-once); test that show_version: false suppresses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions