Skip to content

Add multi-day history rings + fix HA editor dropdown components#6

Merged
maglerod merged 3 commits into
maglerod:mainfrom
sxdjt:main
Apr 27, 2026
Merged

Add multi-day history rings + fix HA editor dropdown components#6
maglerod merged 3 commits into
maglerod:mainfrom
sxdjt:main

Conversation

@sxdjt
Copy link
Copy Markdown
Contributor

@sxdjt sxdjt commented Apr 27, 2026

Summary

  • Multi-day history rings: any history/consumption layer can now render N concentric rings (one per day, max 7) by setting days: N. Outer ring = today, inner rings = progressively older days. Includes shared min/max scaling across the group, configurable opacity fade for older rings, and optional day labels.
  • Editor dropdown fixes: replaced all deprecated ha-select / mwc-list-item patterns with ha-selector (select type), and replaced boolean ha-select fields with ha-switch. This resolves visual editor dropdowns that stopped working in recent HA versions.

Background

This reimplements PR #4 (multi-day rings). That PR was closed because the local development repo was accidentally deleted. This is a clean reimplementation against the current v1.0.8 Beta codebase.

Changes

dist/andy-stats-clock.js

Editor fixes

  • ha-select / mwc-list-item replaced with ha-selector (select type) for: clock mode, layer type, value source, history day, color mode, center layer type, bottom layer type, day label format, day label position
  • Boolean ha-select fields replaced with ha-switch for: show hour labels, show minute ticks, hands share center pivot, enable hour/minute/second hand, center show icon, bottom show icon

Multi-day rings

  • New _getHistoryForDay(lc, hass, stateObj, dayOffset) - fetches and caches one day's hourly buckets per ring. Cache keys are scoped per entity + layer + day offset + segment count. TTL: 5 min for today, 10 min for past days. Includes forward/backward fill and future-hour nulling for today.
  • _buildLayerData() rewritten to pre-expand layers with days > 1 into N entries before radius assignment, so each day-ring occupies its own concentric slot. A second pass shares min/max across the group for a consistent color scale.
  • Segment rendering: multi-day fade applied per ring (opacity * max(0, 1 - dayIndex * fadeStep)); stats markers suppressed on non-today rings.
  • New _renderDayLabel(cfg, layer) - SVG text label at ring midpoint in relative ("Today", "Yesterday", "2d ago") or date ("Jan 15") format.
  • Editor: multi-day section added with controls for days count, fade, fade step, day labels, label format, label position. "History day" selector and "Keep values across midnight" are hidden automatically when days > 1.

CHANGELOG.md (new)

Documents both the editor fixes and the multi-day feature.

MULTI-DAY-RINGS.md (new)

Proposed documentation for the README - config reference table and YAML examples. The maintainer can copy the relevant sections directly into README.md.

New layer config keys

Key Default Description
days 1 Number of day rings (1-7). 1 = existing single-day behaviour unchanged.
day_fade true Fade opacity on older rings.
day_fade_step 0.25 Opacity reduction per day: base * max(0, 1 - dayIndex * step).
day_labels false Show text label on each ring.
day_label_format relative relative (Today / Yesterday / Nd ago) or date (Jan 15).
day_label_position right Clock position: right, left, top, bottom.
day_label_font_size 3 SVG font size.
day_label_color rgba(255,255,255,0.7) Label text color.

sxdjt added 3 commits April 26, 2026 21:34
- Replace deprecated ha-select/mwc-list-item with ha-selector (select type)
  throughout the visual editor; replace ha-select booleans with ha-formfield+ha-switch
- Add _getHistoryForDay() method for per-day cached history fetching
- Rewrite _buildLayerData() to pre-expand layers with days>1 into N concentric
  rings (one per day), sharing min/max scale across the group
- Add multi-day opacity fade (day_fade, day_fade_step) for older day rings
- Guard stats markers to today ring only in multi-day mode
- Add _renderDayLabel() for relative/date format labels on day rings
- Add multi-day editor section with days, fade, labels, format, position controls
- Guard History day selector and Keep across midnight to single-day mode only
@maglerod maglerod merged commit 31a0e1e into maglerod:main Apr 27, 2026
1 check passed
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.

2 participants