Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9f690c9
feat(automation): compare a learned number in a condition (service)
Developer-Simon Nov 22, 2026
da541e8
feat(autolearn): parse the learned_value condition
Developer-Simon Nov 22, 2026
672ca29
feat(automations): edit the learned_value condition
Developer-Simon Nov 22, 2026
ae0c8e1
feat(automations): edit the learned_value fields in the rule card
Developer-Simon Nov 22, 2026
7f83702
test(automation): add replay vectors for rules and scenarios
Developer-Simon Nov 22, 2026
20ece0f
feat(autolearn): replay energy rules minute by minute in a closed loop
Developer-Simon Nov 22, 2026
e733d17
feat(learnrec): add the replay threshold steps to the limits
Developer-Simon Nov 22, 2026
f76647f
feat(autolearn): build replay days from minutes or stretched quarters
Developer-Simon Nov 22, 2026
f762aae
fix(autolearn): harden the replay against unsupported fields and abse…
Developer-Simon Nov 22, 2026
3d1e2a4
feat(autolearn): wire the minute reader into the learning input and b…
Developer-Simon Nov 22, 2026
488eacd
feat(autolearn): check energy suggestions by replay before showing them
Developer-Simon Nov 22, 2026
2d4a899
feat(automations): add the shift start and battery full templates
Developer-Simon Nov 22, 2026
860a4e5
feat(autolearn): suggest switching loads into the typical surplus window
Developer-Simon Nov 22, 2026
47ad596
feat(autolearn): register the surplus window detector
Developer-Simon Nov 22, 2026
d977098
fix(automations): prefill the surplus templates from a suggestion
Developer-Simon Nov 22, 2026
a78819a
feat(autolearn): rate surplus thresholds by replaying them
Developer-Simon Nov 22, 2026
a39d13e
feat(autolearn): register the threshold rating
Developer-Simon Nov 22, 2026
af6f920
feat(autolearn): suggest moving cycles from grid into surplus
Developer-Simon Nov 22, 2026
a1b6eca
feat(autolearn): register the load shift detector
Developer-Simon Nov 22, 2026
d1b835a
fix(automations): prefill the shift start template from a suggestion
Developer-Simon Nov 22, 2026
cbe1805
feat(autolearn): offer loads after the battery is full
Developer-Simon Nov 22, 2026
747fa07
fix(automations): prefill the battery full template from a suggestion
Developer-Simon Nov 22, 2026
b2fba9d
feat(autolearn): give the learning input the steps and the regulator …
Developer-Simon Nov 22, 2026
d434abd
feat(autolearn): tune the zero feed-in regulator from its own steps
Developer-Simon Nov 22, 2026
4091025
feat(autolearn): register the regulator quality check
Developer-Simon Nov 22, 2026
5b25c1b
feat(autolearn): give the rule checker the replay input
Developer-Simon Nov 22, 2026
0215f5e
feat(autolearn): use minute noise and the condition signal in the rul…
Developer-Simon Nov 22, 2026
96b1a20
feat(autolearn): word the cooldown fix and the signal feature
Developer-Simon Nov 22, 2026
f0ec18a
fix(autolearn): cache the replay input and keep scenario findings vis…
Developer-Simon Nov 22, 2026
d6df277
fix(automations): apply a regulator fix to the scenario draft
Developer-Simon Nov 22, 2026
1b7c79a
fix(autolearn): show one scale bar per regulator parameter and drop t…
Developer-Simon Nov 22, 2026
99970b7
feat(autolearn): seed energy suggestions in the demo
Developer-Simon Nov 22, 2026
06cd9e3
feat(autolearn): seed a pendulating regulator in the demo
Developer-Simon Nov 22, 2026
f5e993c
fix(demo): keep the pendulating regulator off the live output topic
Developer-Simon Nov 22, 2026
fa34bb8
docs(automations): describe replay based energy suggestions
Developer-Simon Nov 22, 2026
e98a332
fix(automations): style the parameter name above each regulator scale…
Developer-Simon Nov 22, 2026
5e08c00
chore(dashboard): bump the cache-bust marks for energy suggestions
Developer-Simon Nov 22, 2026
78ec0a9
fix(demo): feed the demo regulator its own load profile
Developer-Simon Nov 22, 2026
3f47e5a
feat(autolearn): seed a surplus window for the demo dryer
Developer-Simon Nov 22, 2026
e7f86ce
feat(autolearn): seed a load shift for the demo dishwasher
Developer-Simon Nov 22, 2026
4b1c051
fix(autolearn): give the surplus window its curve and target block
Developer-Simon Nov 22, 2026
4b75e8f
feat(automations): build the shift start as one scenario
Developer-Simon Nov 22, 2026
a716e0d
fix(automations): load the shift suggestion for the dishwasher into t…
Developer-Simon Nov 22, 2026
56b157e
fix(automations): show the shift start time as a clock in the suggestion
Developer-Simon Nov 22, 2026
8c50b41
fix(monitoring): list the regulator quality finding with its facts
Developer-Simon Nov 22, 2026
0010fc8
fix(automations): show the replayed triggers instead of the burst spa…
Developer-Simon Nov 22, 2026
3c44aa1
fix(automations): draw the replayed triggers of the events evidence
Developer-Simon Nov 22, 2026
0edcbe0
fix(autolearn): read the regulator steps from the files after a start
Developer-Simon Nov 22, 2026
054b01a
feat(automations): show findings on scenario cards
Developer-Simon Nov 22, 2026
5116883
fix(automations): open the scenario finding with its own key
Developer-Simon Nov 22, 2026
0134794
feat(automations): ease the target curve and the scale bars into the …
Developer-Simon Nov 22, 2026
a185d8b
chore(dashboard): bump the cache-bust marks for the evidence animation
Developer-Simon Nov 22, 2026
2bb3b06
fix(automations): keep the target bar at its own opacity after the en…
Developer-Simon Nov 22, 2026
6c6ae6e
chore(release): bump component versions
Nov 23, 2026
b4781f1
docs(changelog): update changelogs
Nov 23, 2026
043e0f6
docs(changelog): update changelogs
Nov 23, 2026
c9a4a62
fix(changelog): shorten the English highlight of the replay suggestions
Developer-Simon Nov 23, 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
8 changes: 8 additions & 0 deletions changelog/highlights/295.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"de": {
"*": "Automationsvorschläge für Überschuss und Lastverschiebung werden an deinen Daten geprüft"
},
"en": {
"*": "Automation suggestions for surplus and load shifts are checked against your data"
}
}
58 changes: 55 additions & 3 deletions dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## v0.11.22-pre.32 (2026-11-06)
## v0.11.22-pre.33 (2026-11-06)

### Features

Expand Down Expand Up @@ -32,6 +32,37 @@
- **automations:** Learning knows device cycles, the PV reserve and the remaining surplus of the day (#289) (5d86b6b)
- **monitoring:** A Monitoring tab with notices, acknowledgement and all learned values (#291) (7ae50a9)
- **autolearn:** The rule check finds feedback, competition for the surplus, a rising base load and battery problems (#292) (142387b)
- **autolearn:** The node records minute values and keeps every regulator step as a base for learning (#293) (19e65e7)
- **autolearn:** parse the learned_value condition (da541e8)
- **automations:** edit the learned_value condition (672ca29)
- **automations:** edit the learned_value fields in the rule card (ae0c8e1)
- **autolearn:** replay energy rules minute by minute in a closed loop (20ece0f)
- **learnrec:** add the replay threshold steps to the limits (e733d17)
- **autolearn:** build replay days from minutes or stretched quarters (f76647f)
- **autolearn:** wire the minute reader into the learning input and borrow minute shape (3d1e2a4)
- **autolearn:** check energy suggestions by replay before showing them (488eacd)
- **automations:** add the shift start and battery full templates (2d4a899)
- **autolearn:** suggest switching loads into the typical surplus window (860a4e5)
- **autolearn:** register the surplus window detector (47ad596)
- **autolearn:** rate surplus thresholds by replaying them (a78819a)
- **autolearn:** register the threshold rating (a39d13e)
- **autolearn:** suggest moving cycles from grid into surplus (af6f920)
- **autolearn:** register the load shift detector (a1b6eca)
- **autolearn:** offer loads after the battery is full (cbe1805)
- **autolearn:** give the learning input the steps and the regulator tuning (b2fba9d)
- **autolearn:** tune the zero feed-in regulator from its own steps (d434abd)
- **autolearn:** register the regulator quality check (4091025)
- **autolearn:** give the rule checker the replay input (5b25c1b)
- **autolearn:** use minute noise and the condition signal in the rule checks (0215f5e)
- **autolearn:** word the cooldown fix and the signal feature (96b1a20)
- **autolearn:** seed energy suggestions in the demo (99970b7)
- **autolearn:** seed a pendulating regulator in the demo (06cd9e3)
- **autolearn:** seed a surplus window for the demo dryer (3f47e5a)
- **autolearn:** seed a load shift for the demo dishwasher (e7f86ce)
- **automations:** build the shift start as one scenario (4b75e8f)
- **automations:** show findings on scenario cards (054b01a)
- **automations:** ease the target curve and the scale bars into the evidence (0134794)
- **autolearn:** Automation suggestions for surplus and load shifts are checked against your data (#295)
- **learnrec:** resolve where the minute recording lives (972c4aa)
- **learnrec:** add the binary day format of the minute recording (f0e0eec)
- **learnrec:** keep minute values in RAM and append them to the chosen drive (64aff34)
Expand All @@ -43,7 +74,6 @@
- **settings:** add the texts for the minute recording card (81d9b09)
- **settings:** choose where minute values are kept (d6e14c7)
- **autolearn:** seed minute values and regulator steps in the demo (956b559)
- **autolearn:** The node records minute values and keeps every regulator step as a base for learning (#293)
- **autolearn:** let a fix change several rules and estimate signal noise (80c444e)
- **autolearn:** flag rules whose own load flips their condition (67cbc32)
- **autolearn:** name feedback as the cause of flapping rules (f6ea384)
Expand Down Expand Up @@ -299,10 +329,29 @@
- **storage:** offer sticks with several partitions as a group and format single partitions (#243) (c4e6d33)
- **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)
- **autolearn:** harden the replay against unsupported fields and absent keys (f762aae)
- **automations:** prefill the surplus templates from a suggestion (d977098)
- **automations:** prefill the shift start template from a suggestion (d1b835a)
- **automations:** prefill the battery full template from a suggestion (747fa07)
- **autolearn:** cache the replay input and keep scenario findings visible (f0ec18a)
- **automations:** apply a regulator fix to the scenario draft (d6df277)
- **autolearn:** show one scale bar per regulator parameter and drop the unsafe entity (1b7c79a)
- **demo:** keep the pendulating regulator off the live output topic (f5e993c)
- **automations:** style the parameter name above each regulator scale bar (e98a332)
- **demo:** feed the demo regulator its own load profile (78ec0a9)
- **autolearn:** give the surplus window its curve and target block (4b1c051)
- **automations:** load the shift suggestion for the dishwasher into the assistant (a716e0d)
- **automations:** show the shift start time as a clock in the suggestion (56b157e)
- **monitoring:** list the regulator quality finding with its facts (8c50b41)
- **automations:** show the replayed triggers instead of the burst span in the frequent evidence (0010fc8)
- **automations:** draw the replayed triggers of the events evidence (3c44aa1)
- **autolearn:** read the regulator steps from the files after a start (0edcbe0)
- **automations:** open the scenario finding with its own key (5116883)
- **automations:** keep the target bar at its own opacity after the entrance (2bb3b06)
- **backup:** A restore stays in place even when the battery state cannot be written (#288) (e5c5437)
- **autolearn:** write step files per scenario and day, drop deadband from figures (8f2a75a)
- **dashboard:** bound the step ring by the RAM days and log slow flushes (0046eee)
- **settings:** format the drive free space in GB (2c55808)
- **backup:** A restore stays in place even when the battery state cannot be written (#288) (e5c5437)
- **autolearn:** drop findings whose fix is saved and show an early full battery in Monitoring (cb2d65b)
- **automations:** keep learned findings while a fix sits in the draft (715cbfd)
- **automations:** preselect the switch of night off and quiet off suggestions (e3a0952)
Expand Down Expand Up @@ -411,6 +460,7 @@

### Documentation

- **automations:** describe replay based energy suggestions (fa34bb8)
- **monitoring:** document the monitoring page and add the smoke check (9802fe9)
- **storage:** describe the system disk breakdown (b2222d8)
- **storage:** explain sticks with several partitions and extend the smoke check (7e75f7a)
Expand Down Expand Up @@ -438,6 +488,8 @@

### Chores

- **dashboard:** bump the cache-bust marks for energy suggestions (5e08c00)
- **dashboard:** bump the cache-bust marks for the evidence animation (a185d8b)
- **dashboard:** bump the cache-bust marks for the minute recording (604eb49)
- **dashboard:** bump the cache-bust mark of the settings page (84aa771)
- **dashboard:** bump the cache-bust marks for energy findings (85a44b4)
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.32
v0.11.22-pre.33
4 changes: 4 additions & 0 deletions dashboard/cmd/dashboard/learn_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ func registerEnergyDetectors(e *autolearn.Engine, reserve func() (float64, bool,
e.Register(autolearn.PVReserveDetector(reserve))
e.Register(autolearn.LearnCyclesDetector)
e.Register(autolearn.NewLearnSurplusDetector(check))
e.Register(autolearn.SurplusDetector)
e.Register(autolearn.ShiftDetector)
e.Register(autolearn.ThresholdDetector)
e.Register(autolearn.RegulatorDetector)
}

// learnOutdoor finds the outdoor temperature entity by its unique id among the
Expand Down
8 changes: 8 additions & 0 deletions dashboard/cmd/dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ func main() {
})
// Die Regelpruefung prueft PV-Schwellen gegen dieselbe Bestkurve wie die Engine.
automationChecker.SetPV(pvSource)
// Die Regelpruefung liest fuer Nachspiel und Minutenrauschen dieselben Daten wie die Engine.
automationChecker.SetReplaySource(func() *autolearn.Input {
return automationEngine.ReplayInput(time.Now())
})
// Herabstufung: nur bei automatischer Stufe rueckt die gemerkte Stufe eine
// nach unten. Eine feste Stufe der Einstellungen bleibt unberuehrt.
engineDowngrade := func() {
Expand Down Expand Up @@ -786,6 +790,10 @@ func main() {
})
learnHub.AddMinute("minutes", minutes.store)
var minuteReader learnrec.Reader = minutes.store
// Die Minutenaufzeichnung fuer das Nachspielen der Engine.
automationEngine.SetMinutes(func() learnrec.Reader { return minuteReader })
// Die Reglerschritte fuer die Regelguete der Nulleinspeisung.
automationEngine.SetSteps(minutes.steps.Steps)
go runStorageResume(ctx, storageService)
// Die Belegung der Systemplatte: in der Demo feste Werte, sonst eine Messung
// im Hintergrund, die alle zehn Minuten erneuert wird.
Expand Down
49 changes: 46 additions & 3 deletions dashboard/internal/autolearn/applied.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,23 @@ func OpsApplied(fix Fix, doc Doc) bool {
}
seen := false
for _, g := range groups {
rule := ruleNamed(doc, g.RuleID)
if rule == nil {
// A regulator fix names a scenario by its ID, a rule fix names a rule.
if rule := ruleNamed(doc, g.RuleID); rule != nil {
for _, op := range g.Ops {
got, ok := ruleValueAt(*rule, op.Path)
if !ok || !sameValue(got, op.Value) {
return false
}
seen = true
}
continue
}
sc := scenarioNamed(doc, g.RuleID)
if sc == nil {
return false
}
for _, op := range g.Ops {
got, ok := ruleValueAt(*rule, op.Path)
got, ok := scenarioValueAt(*sc, op.Path)
if !ok || !sameValue(got, op.Value) {
return false
}
Expand All @@ -131,6 +142,38 @@ func ruleNamed(doc Doc, id string) *Rule {
return nil
}

// scenarioNamed returns the scenario with the given ID, nil without one.
func scenarioNamed(doc Doc, id string) *Scenario {
for i := range doc.Scenarios {
if doc.Scenarios[i].ID == id {
return &doc.Scenarios[i]
}
}
return nil
}

// scenarioValueAt reads the regulator fields that the regulator fixes write:
// while.regulator.gain, deadband_w and max_change_w. A scenario without a
// regulator and any other path report false. Without a max_change_w limit the
// value is nil, which no fix writes.
func scenarioValueAt(sc Scenario, path []any) (any, bool) {
if sc.Regulator == nil || len(path) != 3 || path[0] != "while" || path[1] != "regulator" {
return nil, false
}
switch path[2] {
case "gain":
return sc.Regulator.Gain, true
case "deadband_w":
return sc.Regulator.DeadbandW, true
case "max_change_w":
if sc.Regulator.MaxChangeW == nil {
return nil, true
}
return *sc.Regulator.MaxChangeW, true
}
return nil, false
}

// ruleValueAt reads a rule field or a field of one condition, the paths the
// fixes write. Any other path reports false.
func ruleValueAt(rule Rule, path []any) (any, bool) {
Expand Down
62 changes: 62 additions & 0 deletions dashboard/internal/autolearn/applied_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,65 @@ func TestOpsAppliedSingleRuleAndOddCases(t *testing.T) {
t.Fatal("index out of range, want not applied")
}
}

// regulatorDoc is a document with one regulator scenario "reg" of gain 0.8, deadband 20 W
// and no max_change_w limit.
func regulatorDoc() Doc {
return Doc{Scenarios: []Scenario{{ID: "reg", Enabled: true, Regulator: &RegulatorSpec{Gain: 0.8, DeadbandW: 20}}}}
}

func regulatorFix(path string, value any) Fix {
return Fix{Code: "set_regulator", RuleID: "reg", Ops: []Op{{Path: []any{"while", "regulator", path}, Value: value}}}
}

func TestOpsAppliedReadsScenarioRegulator(t *testing.T) {
doc := regulatorDoc()
if !OpsApplied(regulatorFix("gain", 0.8), doc) {
t.Fatal("gain already at 0.8, want applied")
}
if OpsApplied(regulatorFix("gain", 0.6), doc) {
t.Fatal("gain 0.8 against 0.6, want not applied")
}
if !OpsApplied(regulatorFix("deadband_w", 20.0), doc) {
t.Fatal("deadband 20 W, want applied")
}
if OpsApplied(regulatorFix("max_change_w", 300.0), doc) {
t.Fatal("no max_change_w limit, want not applied")
}
limited := regulatorDoc()
limit := 300.0
limited.Scenarios[0].Regulator.MaxChangeW = &limit
if !OpsApplied(regulatorFix("max_change_w", 300.0), limited) {
t.Fatal("max_change_w 300, want applied")
}
}

func TestOpsAppliedScenarioNeedsRegulatorAndKnownPath(t *testing.T) {
doc := regulatorDoc()
if OpsApplied(Fix{Code: "set_regulator", RuleID: "gibt_es_nicht", Ops: []Op{{Path: []any{"while", "regulator", "gain"}, Value: 0.8}}}, doc) {
t.Fatal("unknown scenario id, want not applied")
}
if OpsApplied(Fix{Code: "set_regulator", RuleID: "reg", Ops: []Op{{Path: []any{"while", "regulator", "output"}, Value: 0.8}}}, doc) {
t.Fatal("unknown regulator field, want not applied")
}
noReg := Doc{Scenarios: []Scenario{{ID: "reg", Enabled: true}}}
if OpsApplied(regulatorFix("gain", 0.8), noReg) {
t.Fatal("scenario without a regulator, want not applied")
}
}

func TestOpsAppliedMixesRuleAndScenarioGroups(t *testing.T) {
doc := appliedDoc(t, `{"type":"balance_threshold","field":"battery_soc","comparison":"above","threshold":96,"hysteresis":0,"hold_seconds":0}`)
doc.Scenarios = regulatorDoc().Scenarios
fix := Fix{Code: "mixed", Rules: []RuleOps{
{RuleID: "r1", Ops: []Op{{Path: []any{"conditions", 0, "threshold"}, Value: 96.0}}},
{RuleID: "reg", Ops: []Op{{Path: []any{"while", "regulator", "gain"}, Value: 0.8}}},
}}
if !OpsApplied(fix, doc) {
t.Fatal("rule and scenario both applied, want applied")
}
fix.Rules[1].Ops[0].Value = 0.5
if OpsApplied(fix, doc) {
t.Fatal("scenario not applied, the group as a whole is not applied")
}
}
24 changes: 21 additions & 3 deletions dashboard/internal/autolearn/check_feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const (
feedbackConfirmShare = 0.3
// feedbackMinChanges is the number of switch-ons needed to observe the step.
feedbackMinChanges = 3
// feedbackMinuteDays is the number of minute days the noise is taken from the minutes.
feedbackMinuteDays = 3
)

// feedbackRun lists the feedback findings as candidates. The check is static, so
Expand Down Expand Up @@ -55,8 +57,6 @@ func FeedbackFindings(in *Input) []Finding {
if in == nil || len(in.Doc.Rules) == 0 {
return nil
}
noise := feedbackNoise(in.Days)
reserve := 2 * noise
rules := ruleByID(in.Doc)
var out []Finding
seen := map[string]bool{}
Expand All @@ -76,7 +76,12 @@ func FeedbackFindings(in *Input) []Finding {
continue
}
off, offIdx, xAus, ok := feedbackOffRule(in.Doc, info, on.ID, rules)
if !ok || x-pAnlauf-noise > xAus {
if !ok {
continue
}
noise := feedbackNoiseAt(in, x)
reserve := 2 * noise
if x-pAnlauf-noise > xAus {
continue
}
seen[on.ID] = true
Expand Down Expand Up @@ -220,6 +225,19 @@ func feedbackNoise(days []DayFile) float64 {
return QuarterNoise(series)
}

// feedbackNoiseAt is the noise of the export at the switch-on threshold x. From
// feedbackMinuteDays minute days on it is the minute noise near x, otherwise
// the quarter noise of the days. The quarter noise also stays when no minute
// lies near x.
func feedbackNoiseAt(in *Input, x float64) float64 {
if minuteDayCount(in) >= feedbackMinuteDays {
if n, ok := MinuteNoise(in.Minutes, "b:"+feedbackField, x, in.Now.AddDate(0, 0, -engineHistoryDays), in.Now); ok {
return n
}
}
return feedbackNoise(in.Days)
}

// feedbackInrush is the median start peak of the device over its cycles, or the
// operating power when no cycle has a peak.
func feedbackInrush(days []DayFile, device string, p float64) float64 {
Expand Down
51 changes: 51 additions & 0 deletions dashboard/internal/autolearn/check_feedback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,54 @@ func TestFeedbackDetectorWrapsFindingsAsCandidates(t *testing.T) {
t.Fatalf("candidates = %+v, want one listed feedback candidate", got)
}
}

// fbNoiseFact returns the noise_w fact of the first feedback finding, false without one.
func fbNoiseFact(got []Finding) (float64, bool) {
if len(got) != 1 {
return 0, false
}
for _, f := range got[0].Facts {
if f.Code == "noise_w" {
v, ok := f.Value.(float64)
return v, ok
}
}
return 0, false
}

// TestFeedbackNoiseIsMinuteNoiseWithThreeMinuteDays: with three minute days the
// noise near the switch-on threshold comes from the minutes, with fewer it
// stays the quarter noise of the days.
func TestFeedbackNoiseIsMinuteNoiseWithThreeMinuteDays(t *testing.T) {
loc := berlinLoc(t)
spikes := make([]float32, 1440)
for m := range spikes {
spikes[m] = 1500
if m%10 == 5 {
spikes[m] = 1580
}
}
days := []DayFile{relDay(fbDay(loc, 15)), relDay(fbDay(loc, 16)), relDay(fbDay(loc, 17))}
minutes := func(n int) fakeMinutes {
fm := fakeMinutes{loc: loc, days: map[string]map[string][]float32{}}
for _, d := range days[:n] {
fm.days[d.Day] = map[string][]float32{"b:grid_export": spikes}
}
return fm
}
run := func(fm fakeMinutes) []Finding {
in := relInput(loc, days, fbDevice(), fbRule("on", "above", 1500), fbRule("off", "below", 500))
in.Learned = fbLearned(2000)
in.Minutes = fm
return FeedbackFindings(in)
}

noise, ok := fbNoiseFact(run(minutes(3)))
if !ok || noise != 80 {
t.Fatalf("noise with three minute days = %v (found %v), want the minute noise 80", noise, ok)
}
noise, ok = fbNoiseFact(run(minutes(2)))
if !ok || noise != 0 {
t.Fatalf("noise with two minute days = %v (found %v), want the quarter noise 0", noise, ok)
}
}
Loading
Loading