Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Changelog

## [Unreleased] - sxdjt fork

### Changed

- Replaced deprecated `ha-select` / `mwc-list-item` dropdown pattern throughout
the visual editor with `ha-selector` (select type), matching current Home
Assistant standards. Affected fields: clock mode, layer type, value source,
history day, color mode, center layer type, bottom layer type, day label
format, day label position.
- Replaced deprecated boolean `ha-select` fields with `ha-formfield` + `ha-switch`
throughout the visual editor. Affected fields: show hour labels, show minute
ticks, hands share center pivot, enable hour/minute/second hand, center show
icon, bottom show icon.

### Added

- **Multi-day history rings** (reimplementation of PR #4 - original local repo
was accidentally deleted): a history/consumption layer can now be configured
with `days: N` (1-7) to render N concentric rings, one per day. The outermost
ring is today; inner rings are progressively older days.
- New `_getHistoryForDay(lc, hass, stateObj, dayOffset)` method fetches and
caches one day's hourly bucket data per ring. Cache keys are scoped per
entity, layer, day offset, and segment count. TTL is 5 minutes for today,
10 minutes for past days.
- `_buildLayerData()` pre-expands multi-day layers into an expanded list before
radius assignment, so each day-ring occupies its own concentric slot. A
second pass shares min/max across all rings in a multi-day group so the
color scale is consistent across days.
- `day_fade` (default `true`) and `day_fade_step` (default `0.25`) - fade
opacity applied per-ring for older days so recent data is visually dominant.
- Stats markers (min/max/avg) are suppressed on non-today rings to avoid
visual clutter.
- `day_labels` - optional SVG text label on each ring showing relative ("Today",
"Yesterday", "2d ago") or absolute date ("Jan 15") format, configurable via
`day_label_format`, `day_label_position`, `day_label_font_size`,
`day_label_color`.
- New `_renderDayLabel(cfg, layer)` method produces the SVG label element.
- "History day" selector and "Keep values across midnight" are hidden in the
visual editor when `days > 1`, as they are not applicable in multi-day mode.
- Multi-day editor section added under history/consumption layers with controls
for: days count, fade toggle, fade step, day labels toggle, label format,
label position.
121 changes: 121 additions & 0 deletions MULTI-DAY-RINGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Multi-Day History Rings

Any history or consumption layer can render multiple concentric rings - one per
day - by setting `days` to a value greater than 1. The outermost ring is always
today; each inner ring is one day older.

This makes it easy to compare today's energy price or consumption pattern
against previous days at a glance, using the same entity and color scale.

---

## How it works

- Each day fetches its own hourly buckets from the HA history API, cached
independently (5-minute TTL for today, 10-minute TTL for past days).
- All rings in the group share the same min/max scale so colors are directly
comparable across days.
- Older rings fade progressively so today's data is visually dominant.
- Stats markers (min/max/avg) are shown only on today's ring.
- "History day" and "Keep values across midnight" are not available in
multi-day mode; set `days: 1` to use those features instead.

---

## Configuration reference

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `days` | integer 1-7 | `1` | Number of day rings. 1 = single-day (existing behaviour). |
| `day_fade` | boolean | `true` | Reduce opacity on older day rings. |
| `day_fade_step` | float 0-1 | `0.25` | Opacity multiplier reduction per day. Ring N opacity = `base * max(0, 1 - N * step)`. |
| `day_labels` | boolean | `false` | Show a text label on each ring. |
| `day_label_format` | `relative` / `date` | `relative` | `relative` = "Today", "Yesterday", "2d ago". `date` = "Jan 15". |
| `day_label_position` | `right` / `left` / `top` / `bottom` | `right` | Clock position of the label on each ring. |
| `day_label_font_size` | number | `3` | SVG font size for day labels. |
| `day_label_color` | color string | `rgba(255,255,255,0.7)` | Day label text color. |

---

## Examples

### 3-day energy price comparison

Show today, yesterday, and two days ago as concentric rings. Older rings fade
to 50% and 25% of the base opacity respectively.

```yaml
type: custom:andy-stats-clock
clock_mode: 24h
layers:
- id: price_multiday
type: price
entity: sensor.nordpool_kwh_se3_sek_3_10_025
price_source: array
attribute: today
thickness: 6
color_mode: intervals
intervals:
- color: "#28c76f"
max: 0.5
- color: "#ff9f43"
max: 1.0
- color: "#ea5455"
max: 999
days: 3
day_fade: true
day_fade_step: 0.25
```

### 7-day consumption with date labels

```yaml
type: custom:andy-stats-clock
clock_mode: 24h
layers:
- id: consumption_week
type: consumption
entity: sensor.electricity_consumption_kwh
thickness: 5
color_mode: gradient
gradient:
- "#1a1a2e"
- "#16213e"
- "#0f3460"
- "#533483"
days: 7
day_fade: true
day_fade_step: 0.12
day_labels: true
day_label_format: date
day_label_position: right
day_label_font_size: 3
day_label_color: "rgba(255,255,255,0.6)"
```

### Single day (unchanged behaviour)

Omitting `days` or setting it to `1` preserves all existing single-day
behaviour, including "History day" offset and "Keep values across midnight".

```yaml
layers:
- id: price_today
type: price
entity: sensor.nordpool_kwh_se3_sek_3_10_025
price_source: array
attribute: today
days: 1 # default - single ring, all existing options available
keep_across_midnight: true
fade_previous_day: true
fade_previous_day_opacity: 0.3
```

---

## Visual editor

Multi-day settings appear in the layer editor under **Multi-day comparison**,
visible for history and consumption layer types. When `days` is set above 1,
the "History day" and "Keep values across midnight" sections are hidden
automatically since they do not apply in multi-day mode.
Loading
Loading