Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f85130f
feat(automations): mark rules that came from a learned suggestion
Developer-Simon Nov 23, 2026
ae2baed
feat(webui): record which suggestion a saved rule came from
Developer-Simon Nov 23, 2026
6e20041
fix(webui): mark rules adopted from the suggestions band
Developer-Simon Nov 23, 2026
a1e9dc6
feat(autolearn): measure the effect of an adopted suggestion against …
Developer-Simon Nov 23, 2026
fbbda8c
fix(autolearn): accept baseline weeks with five days of data
Developer-Simon Nov 23, 2026
f0d3d9e
feat(autolearn): keep the effect of adopted rules in a store
Developer-Simon Nov 25, 2026
d024c0d
feat(autolearn): show the effect of adopted suggestions on the rule a…
Developer-Simon Nov 25, 2026
479c125
feat(autolearn): report when an adopted suggestion drifts with the se…
Developer-Simon Nov 25, 2026
a95dcb5
fix(autolearn): keep the comparison values when a drifted rule is rep…
Developer-Simon Nov 25, 2026
85a5fed
feat(webui): show the effect of adopted suggestions in the band
Developer-Simon Nov 25, 2026
a71c920
feat(webui): show the effect and season drift of adopted suggestions
Developer-Simon Nov 25, 2026
71ee735
feat(demo): show an effect and a season drift
Developer-Simon Nov 25, 2026
baef371
docs(automations): describe learning on one page
Developer-Simon Nov 25, 2026
fdb5ff8
fix(webui): show the assistant for a drift fix and fit the effect card
Developer-Simon Nov 25, 2026
e1052a2
docs(automations): rework monitoring and link the learning page
Developer-Simon Nov 25, 2026
51a586e
fix(autolearn): compare only values that drift with the season
Developer-Simon Nov 25, 2026
872f279
docs(automations): name what can drift with the season
Developer-Simon Nov 25, 2026
7aa2448
fix(backup): include the measured effects in the backup
Developer-Simon Nov 25, 2026
b591b99
fix(autolearn): show only the override count without a measure
Developer-Simon Nov 25, 2026
cfc5906
fix(autolearn): keep rating a surplus window after its rule was adopted
Developer-Simon Nov 25, 2026
c3e766b
feat(demo): show every effect state and drift kind
Developer-Simon Nov 25, 2026
573643f
fix(autolearn): judge the season drift only after a complete daily round
Developer-Simon Nov 25, 2026
65558cd
fix(demo): keep every effect state visible on any day
Developer-Simon Nov 25, 2026
aa987aa
test(demo): expect a sure effect beside the estimates
Developer-Simon Nov 29, 2026
fa93e53
chore(webui): bump the cache marks of the changed automation assets
Developer-Simon Nov 29, 2026
43f4528
fix(webui): write the drift scale axes in the number format of the page
Developer-Simon Nov 29, 2026
e41a11d
fix(webui): name the scenario in the surplus window drift
Developer-Simon Nov 29, 2026
49a32f9
fix(demo): adopt the surplus window as a scenario and count one effec…
Developer-Simon Nov 29, 2026
0b4bef6
fix(webui): fit the effect axis on phones and say what a threshold fi…
Developer-Simon Nov 29, 2026
222cf12
fix(webui): label only the ends of the before and since axis
Developer-Simon Nov 29, 2026
fa55c0a
feat(webui): let a tour expand the suggestions band
Developer-Simon Nov 29, 2026
f4755bb
feat(monitoring): check the results of adopted suggestions in Monitoring
Developer-Simon Nov 29, 2026
0f29510
chore(release): bump component versions
Nov 29, 2026
dcc66ee
docs(changelog): update changelogs
Nov 29, 2026
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
65 changes: 65 additions & 0 deletions changelog/highlights/300.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"de": {
"*": "Monitoring prüft, was übernommene Vorschläge bringen, Regeln melden einen Saisonwechsel"
},
"en": {
"*": "Monitoring checks the results of adopted suggestions and rules report a season drift"
},
"tour": {
"*": {
"steps": [
{
"device": "any",
"need": "view_monitoring",
"open": [
"monitoring-effect"
],
"panel": "monitoring-panel",
"target": "monitoring-effect",
"text": {
"de": "Nach dem Übernehmen eines Vorschlags zeigt das Monitoring unter Erfolgskontrolle den Wert vorher und seitdem. Das beginnt nach der ersten vollen Woche.",
"en": "After you adopt a suggestion, Monitoring shows the value before and since under Results check. It appears after the first full week."
},
"title": {
"de": "Erfolgskontrolle",
"en": "Results check"
}
},
{
"device": "any",
"need": "view_automations",
"open": [
"automations-rules"
],
"panel": "automations-panel",
"target": "rule-effect",
"text": {
"de": "Die Regel trägt dasselbe Ergebnis. Wandern ihre Zeiten oder Werte mit der Jahreszeit, warnt die Marke und bietet eine Anpassung an.",
"en": "The rule carries the same result. When its times or values move with the season, the mark warns and offers an adjustment."
},
"title": {
"de": "Die Marke an der Regel",
"en": "The mark on the rule"
}
},
{
"device": "any",
"need": "view_monitoring",
"open": [
"monitoring-learned"
],
"panel": "monitoring-panel",
"target": "monitoring-learned",
"text": {
"de": "Das Monitoring listet, was der Node gelernt hat. Regeln können diese Werte nutzen.",
"en": "Monitoring lists what the node has learned. Rules can use these values."
},
"title": {
"de": "Lernwerte",
"en": "Learned values"
}
}
]
}
}
}
34 changes: 32 additions & 2 deletions dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## v0.11.22-pre.37 (2026-11-06)
## v0.11.22-pre.38 (2026-11-06)

### Features

Expand Down Expand Up @@ -36,10 +36,23 @@
- **autolearn:** Automation suggestions for surplus and load shifts are checked against your data (#295) (6c255ad)
- **autolearn:** Learning functions can take minute values from Home Assistant (#294) (7aa657e)
- **monitoring:** Monitoring shows the forecast check, a year comparison and the learned values as a usual day (#297) (4f93975)
- **dashboard:** show system versions on the versions page (#299) (18a2b0b)
- **automations:** mark rules that came from a learned suggestion (f85130f)
- **webui:** record which suggestion a saved rule came from (ae2baed)
- **autolearn:** measure the effect of an adopted suggestion against the season (a1e9dc6)
- **autolearn:** keep the effect of adopted rules in a store (f0d3d9e)
- **autolearn:** show the effect of adopted suggestions on the rule and in the band (d024c0d)
- **autolearn:** report when an adopted suggestion drifts with the season (479c125)
- **webui:** show the effect of adopted suggestions in the band (85a5fed)
- **webui:** show the effect and season drift of adopted suggestions (a71c920)
- **demo:** show an effect and a season drift (71ee735)
- **demo:** show every effect state and drift kind (c3e766b)
- **webui:** let a tour expand the suggestions band (fa55c0a)
- **monitoring:** check the results of adopted suggestions in Monitoring (f4755bb)
- **automations:** Monitoring checks the results of adopted suggestions and rules report a season drift (#300)
- **dashboard:** read the system package versions (8d025b3)
- **dashboard:** serve system versions to setup users (8e71270)
- **dashboard:** show the kernel and the Debian point release (93d002d)
- **dashboard:** show system versions on the versions page (#299)
- **autolearn:** expose forecast days and the rules that read a learned value (25d731e)
- **demo:** seed a forecast check and a year of season weeks (4a39a77)
- **monitoring:** serve the forecast check and the season weeks from the api (d11383f)
Expand Down Expand Up @@ -354,6 +367,21 @@
- **storage:** wipe old file system signatures before formatting a stick (#245) (aeafa63)
- **storage:** set up, back up and replug the additional drive reliably (#247) (b668394)
- **automations:** correct the learning feature after the full review (#296) (88f3c75)
- **webui:** mark rules adopted from the suggestions band (6e20041)
- **autolearn:** accept baseline weeks with five days of data (fbbda8c)
- **autolearn:** keep the comparison values when a drifted rule is replaced (a95dcb5)
- **webui:** show the assistant for a drift fix and fit the effect card (fdb5ff8)
- **autolearn:** compare only values that drift with the season (51a586e)
- **backup:** include the measured effects in the backup (7aa2448)
- **autolearn:** show only the override count without a measure (b591b99)
- **autolearn:** keep rating a surplus window after its rule was adopted (cfc5906)
- **autolearn:** judge the season drift only after a complete daily round (573643f)
- **demo:** keep every effect state visible on any day (65558cd)
- **webui:** write the drift scale axes in the number format of the page (43f4528)
- **webui:** name the scenario in the surplus window drift (e41a11d)
- **demo:** adopt the surplus window as a scenario and count one effect in hand switches (49a32f9)
- **webui:** fit the effect axis on phones and say what a threshold fix does (0b4bef6)
- **webui:** label only the ends of the before and since axis (222cf12)
- **backup:** A restore stays in place even when the battery state cannot be written (#288) (e5c5437)
- **monitoring:** keep texts and locale out of the insight model (57e2a44)
- **monitoring:** show the legend items for statistics weeks and gaps (82cde6e)
Expand Down Expand Up @@ -518,6 +546,7 @@

### Tests

- **demo:** expect a sure effect beside the estimates (aa987aa)
- **demo:** fake the system packages for the versions page (ca2dc1e)
- **autolearn:** keep the cycle test window open until today (ab438d5)
- **webui:** follow the template cache-bust mark (c30a3db)
Expand All @@ -541,6 +570,7 @@

### Chores

- **webui:** bump the cache marks of the changed automation assets (fa93e53)
- **dashboard:** bump the cache-bust marks for the system card (31ecbb8)
- **dashboard:** move the cache history rows to the current pre-release (8a60da5)
- **monitoring:** drop the texts of the old learned values list (d6da484)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.11.22-pre.37
v0.11.22-pre.38
197 changes: 197 additions & 0 deletions dashboard/cmd/dashboard/learn_effect_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package main

import (
"encoding/json"
"math"
"os"
"path/filepath"
"testing"
"time"

"github.com/Developer-Simon/energy-node-dashboard/internal/autolearn"
)

// effectTestRunner builds an effect runner over a fixed rule document and
// counts the day file loads.
func effectTestRunner(t *testing.T, doc []byte, loads *int) *effectRunner {
t.Helper()
dir := t.TempDir()
return &effectRunner{
store: autolearn.LoadEffectStore(filepath.Join(dir, "effects.json"), nil),
readDoc: func() ([]byte, error) { return doc, nil },
days: func(from, to time.Time) ([]autolearn.DayFile, error) {
*loads++
return nil, nil
},
candidates: func() []autolearn.Candidate { return nil },
shown: func() map[string]autolearn.Shown { return nil },
season: autolearn.LoadSeasonStore(filepath.Join(dir, "season.json"), nil),
enabled: func() bool { return true },
// No complete daily round unless a test says so.
round: func() (time.Time, bool) { return time.Time{}, false },
}
}

func TestEffectRunnerLoadsDaysOnlyForNewRuleOrDailyRun(t *testing.T) {
loads := 0
r := effectTestRunner(t, []byte(effectRuleDoc), &loads)
now := time.Date(2026, 11, 25, 10, 0, 0, 0, time.Local)

r.Run(now)
r.Run(now.Add(time.Minute))
r.Run(now.Add(2 * time.Minute))
if loads != 1 {
t.Fatalf("day file loads over three rounds of one day = %d, want 1 (the new rule)", loads)
}
if r.store.Len() != 1 {
t.Fatalf("entries = %d, want 1 for the learned rule", r.store.Len())
}

// The next morning the daily run loads the day files again, once.
r.Run(time.Date(2026, 11, 26, 4, 0, 0, 0, time.Local))
if loads != 2 {
t.Fatalf("day file loads after the daily run = %d, want 2", loads)
}
}

func TestEffectRunnerUnreadableDocumentKeepsEntries(t *testing.T) {
loads := 0
r := effectTestRunner(t, []byte(effectRuleDoc), &loads)
now := time.Date(2026, 11, 25, 10, 0, 0, 0, time.Local)
r.Run(now)

r.readDoc = func() ([]byte, error) { return nil, os.ErrNotExist }
r.Run(now.AddDate(0, 0, 1).Add(5 * time.Hour))
if r.store.Len() != 1 {
t.Fatalf("entries after an unreadable document = %d, want 1 kept", r.store.Len())
}
}

func TestEffectRunnerDisabledDoesNothing(t *testing.T) {
loads := 0
r := effectTestRunner(t, []byte(effectRuleDoc), &loads)
r.enabled = func() bool { return false }
r.Run(time.Date(2026, 11, 25, 10, 0, 0, 0, time.Local))
if loads != 0 || r.store.Len() != 0 {
t.Fatalf("disabled runner loads = %d, entries = %d, want none", loads, r.store.Len())
}
}

func TestEffectRunnerTakesCandidateValuesWhenNotShown(t *testing.T) {
dir := t.TempDir()
effects := filepath.Join(dir, "effects.json")
loads := 0
r := effectTestRunner(t, []byte(effectRuleDoc), &loads)
r.store = autolearn.LoadEffectStore(effects, nil)
r.candidates = func() []autolearn.Candidate {
return []autolearn.Candidate{{
Finding: autolearn.Finding{ID: "switchtime:r1:dev-a"},
Values: map[string]float64{"time": 1305},
Spread: map[string]float64{"time": 10},
}}
}
now := time.Date(2026, 11, 25, 10, 0, 0, 0, time.Local)
r.round = func() (time.Time, bool) { return now.Add(-time.Hour), true }
r.Run(now)

raw, err := os.ReadFile(effects)
if err != nil {
t.Fatalf("effects file: %v", err)
}
var f struct {
Entries []struct {
Rule string `json:"rule"`
Values map[string]float64 `json:"values"`
Series []float64 `json:"series"`
} `json:"entries"`
}
if err := json.Unmarshal(raw, &f); err != nil {
t.Fatalf("effects file: %v", err)
}
if len(f.Entries) != 1 || f.Entries[0].Rule != "r1" {
t.Fatalf("entries = %+v, want one entry for r1", f.Entries)
}
if f.Entries[0].Values["time"] != 1305 {
t.Errorf("values = %v, want the candidate time 1305", f.Entries[0].Values)
}
if len(f.Entries[0].Series) != 1 {
t.Errorf("series = %v, want one nightly value after the new entry", f.Entries[0].Series)
}
}

// effectSeriesOnDisk reads the season drift series of the first entry from the
// effect store file.
func effectSeriesOnDisk(t *testing.T, path string) []float64 {
t.Helper()
raw, err := os.ReadFile(path)
if err != nil {
t.Fatalf("effects file: %v", err)
}
var f struct {
Entries []struct {
Series []float64 `json:"series"`
} `json:"entries"`
}
if err := json.Unmarshal(raw, &f); err != nil {
t.Fatalf("effects file: %v", err)
}
if len(f.Entries) != 1 {
t.Fatalf("entries = %d, want 1", len(f.Entries))
}
return f.Entries[0].Series
}

// TestEffectRunnerDriftWaitsForCompleteRound checks that the season drift is
// judged only after a complete daily round: a round without one, after a restart,
// leaves the stored drift alone, and a new complete round updates it, on the same day too.
func TestEffectRunnerDriftWaitsForCompleteRound(t *testing.T) {
path := filepath.Join(t.TempDir(), "effects.json")
loads := 0
r := effectTestRunner(t, []byte(effectRuleDoc), &loads)
r.store = autolearn.LoadEffectStore(path, nil)
shift := 1305.0
r.candidates = func() []autolearn.Candidate {
return []autolearn.Candidate{{
Finding: autolearn.Finding{ID: "switchtime:r1:dev-a"},
Values: map[string]float64{"time": shift},
Spread: map[string]float64{"time": 10},
}}
}
now := time.Date(2026, 11, 25, 10, 0, 0, 0, time.Local)
dailyAt := time.Date(2026, 11, 25, 3, 30, 0, 0, time.Local)

// The new entry comes before any complete round: no drift yet.
r.Run(now)
if got := effectSeriesOnDisk(t, path); len(got) != 0 {
t.Fatalf("series before a complete round = %v, want none", got)
}

// The first complete round judges the drift, the value is 0 at 1305.
r.round = func() (time.Time, bool) { return dailyAt, true }
r.Run(now)
if got := effectSeriesOnDisk(t, path); len(got) != 1 || got[0] != 0 {
t.Fatalf("series after a complete round = %v, want [0]", got)
}

// The candidate moved, but the round is incomplete: the stored drift stays.
shift = 1250
r.round = func() (time.Time, bool) { return time.Time{}, false }
r.Run(now.Add(time.Hour))
if got := effectSeriesOnDisk(t, path); len(got) != 1 || got[0] != 0 {
t.Fatalf("series during an incomplete round = %v, want [0] kept", got)
}

// The same complete round again changes nothing.
r.round = func() (time.Time, bool) { return dailyAt, true }
r.Run(now.Add(2 * time.Hour))
if got := effectSeriesOnDisk(t, path); len(got) != 1 || got[0] != 0 {
t.Fatalf("series after the same round = %v, want [0] kept", got)
}

// A new complete round the same day judges the drift again: (1250-1305)/10.
r.round = func() (time.Time, bool) { return dailyAt.Add(time.Hour), true }
r.Run(now.Add(3 * time.Hour))
if got := effectSeriesOnDisk(t, path); len(got) != 1 || math.Abs(got[0]+5.5) > 1e-6 {
t.Fatalf("series after a new complete round = %v, want [-5.5]", got)
}
}
Loading
Loading