From c685afe9f21d1b410e198370dff590a68c4f0820 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Tue, 9 Jun 2026 14:01:53 +0200 Subject: [PATCH] Metrics: fix entity titles for db loadpoints (#30634) --- cmd/setup.go | 7 ------- core/loadpoint.go | 9 +++++---- core/loadpoint_api.go | 6 ++++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/setup.go b/cmd/setup.go index 9d421e57a..79e2216d0 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -1328,13 +1328,6 @@ func newLoadpoint(idx int, name string, other map[string]any, settingsFn func(*u return lp, err } - // lazily update entity title - if title := lp.GetTitle(); title != "" { - if err := collector.UpdateTitle(title); err != nil { - return lp, err - } - } - return lp, nil } diff --git a/core/loadpoint.go b/core/loadpoint.go index 6f5c98c00..a75d6b02a 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -213,10 +213,6 @@ func NewLoadpointFromConfig(log *util.Logger, settings settings.Settings, collec lp.mode = api.ModeOff } - if lp.Title != "" { - lp.setTitle(lp.Title) - } - if lp.Priority > 0 { lp.setPriority(lp.Priority) } @@ -274,6 +270,11 @@ func NewLoadpointFromConfig(log *util.Logger, settings settings.Settings, collec lp.chargeEnergy = collector } + // set title after collector is wired to refresh the metrics entity + if lp.Title != "" { + lp.setTitle(lp.Title) + } + // phase switching defaults based on charger capabilities if !lp.hasPhaseSwitching() { phases := lp.getChargerPhysicalPhases() diff --git a/core/loadpoint_api.go b/core/loadpoint_api.go index 69963265a..e8403bc2e 100644 --- a/core/loadpoint_api.go +++ b/core/loadpoint_api.go @@ -127,6 +127,12 @@ func (lp *Loadpoint) setTitle(title string) { lp.title = title lp.publish(keys.Title, lp.title) lp.settings.SetString(keys.Title, lp.title) + + if lp.chargeEnergy != nil { + if err := lp.chargeEnergy.UpdateTitle(title); err != nil { + lp.log.ERROR.Printf("update title: %v", err) + } + } } // GetStatus returns the charging status