Metrics: fix entity titles for db loadpoints (#30634)

This commit is contained in:
Michael Geers 2026-06-09 14:01:53 +02:00 • committed by GitHub
parent 6e27156c85
commit c685afe9f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 11 deletions

View file

@ -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
}

View file

@ -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()

View file

@ -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