-
Notifications
You must be signed in to change notification settings - Fork 11
fix(control,prices): stop logging normal operation as warnings #1443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": patch | ||
| --- | ||
|
|
||
| The log no longer fills with warnings about normal operation. The meter clamp, which holds the grid at its target and stops the battery from exporting while covering the house, is logged once when it engages instead of as a warning every control tick. On the home box that was about 3,000 warnings a night. A failed fetch of tomorrow's prices before they are published, around 13:00, is logged at debug level; a failure for today, or for tomorrow after publication, is still a warning. Real warnings, such as a cloud charger going offline, stand out again in `journalctl` and in the support report. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -693,16 +693,28 @@ func (s *Service) loop(ctx context.Context) { | |
| // day-ahead is normally on the dataportal. Hourly ticks alone can miss | ||
| // that window for up to an hour. | ||
| func nextDayAheadCatch(now time.Time) time.Time { | ||
| target := dayAheadPublished(now) | ||
| if !now.Before(target) { | ||
| target = target.Add(24 * time.Hour) | ||
| } | ||
| return target | ||
| } | ||
|
|
||
| // notPublishedYet reports whether a failed fetch for today+offset is the | ||
| // normal answer before tomorrow's day-ahead prices are published. | ||
| func notPublishedYet(offset int, now time.Time) bool { | ||
| return offset == 1 && now.Before(dayAheadPublished(now)) | ||
| } | ||
|
|
||
| // dayAheadPublished is 13:05 Europe/Stockholm on now's date, by when | ||
| // tomorrow's day-ahead prices are normally published. | ||
| func dayAheadPublished(now time.Time) time.Time { | ||
| loc, err := time.LoadLocation("Europe/Stockholm") | ||
| if err != nil { | ||
| loc = time.FixedZone("CET", 3600) | ||
| } | ||
| now = now.In(loc) | ||
| target := time.Date(now.Year(), now.Month(), now.Day(), 13, 5, 0, 0, loc) | ||
| if !now.Before(target) { | ||
| target = target.Add(24 * time.Hour) | ||
| } | ||
| return target | ||
| return time.Date(now.Year(), now.Month(), now.Day(), 13, 5, 0, 0, loc) | ||
| } | ||
|
|
||
| func (s *Service) fetchAndStore(ctx context.Context) { | ||
|
|
@@ -711,7 +723,13 @@ func (s *Service) fetchAndStore(ctx context.Context) { | |
| day := now.AddDate(0, 0, offset) | ||
| rows, err := s.Provider.Fetch(ctx, s.Zone, day) | ||
| if err != nil { | ||
| slog.Warn("price fetch failed", "zone", s.Zone, "day", day.Format("2006-01-02"), "err", err) | ||
| // Tomorrow's day-ahead is not published before about 13:00, so | ||
| // asking earlier is expected to find nothing. | ||
| if notPublishedYet(offset, now) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On hosts whose local timezone differs from Europe/Stockholm, AGENTS.md reference: AGENTS.md:L20-L23 Useful? React with 👍 / 👎. |
||
| slog.Debug("tomorrow's prices are not published yet", "zone", s.Zone, "day", day.Format("2006-01-02"), "err", err) | ||
| } else { | ||
| slog.Warn("price fetch failed", "zone", s.Zone, "day", day.Format("2006-01-02"), "err", err) | ||
| } | ||
| continue | ||
| } | ||
| if len(rows) == 0 { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a clamp tick is followed by any time in
ModeIdleorModeCharge, those modes return above this defer and leavemeterClampLoggedtrue. If the operator later switches back and the clamp engages again, its first event is logged only at debug—and is therefore absent from the production INFO logger—even though the previous clamp episode ended during the intervening mode. Install the reset before these short-circuit returns or clear it as part of the mode transition.Useful? React with 👍 / 👎.