Metrics: fix entity titles for db loadpoints (#30634)
This commit is contained in:
parent
6e27156c85
commit
c685afe9f2
3 changed files with 11 additions and 11 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue