From ea381b21fc7269e406c14af30e9a0f9303691916 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 3 Feb 2023 17:52:54 +0100 Subject: [PATCH] chore: use loadpoint Title() instead of Name() --- core/loadpoint.go | 7 +------ core/loadpoint/api.go | 4 ++-- core/loadpoint_api.go | 5 +++++ core/site.go | 2 +- hems/semp/semp.go | 2 +- server/influxdb.go | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index 4056db0a9..925425b3b 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -108,7 +108,7 @@ type Loadpoint struct { sync.Mutex // guard status Mode api.ChargeMode `mapstructure:"mode"` // Charge mode, guarded by mutex - Title string `mapstructure:"title"` // UI title + Title_ string `mapstructure:"title"` // UI title ConfiguredPhases int `mapstructure:"phases"` // Charger configured phase mode 0/1/3 ChargerRef string `mapstructure:"charger"` // Charger reference VehicleRef string `mapstructure:"vehicle"` // Vehicle reference @@ -540,11 +540,6 @@ func (lp *Loadpoint) applyAction(actionCfg api.ActionConfig) { } } -// Name returns the human-readable loadpoint title -func (lp *Loadpoint) Name() string { - return lp.Title -} - // Prepare loadpoint configuration by adding missing helper elements func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Event, lpChan chan<- *Loadpoint) { lp.uiChan = uiChan diff --git a/core/loadpoint/api.go b/core/loadpoint/api.go index 2e7a54531..8b3048ae1 100644 --- a/core/loadpoint/api.go +++ b/core/loadpoint/api.go @@ -13,8 +13,8 @@ type Controller interface { // API is the external loadpoint API type API interface { - // Name returns the defined loadpoint name - Name() string + // Title returns the defined loadpoint title + Title() string // // status diff --git a/core/loadpoint_api.go b/core/loadpoint_api.go index 89da430b6..7a7b9541c 100644 --- a/core/loadpoint_api.go +++ b/core/loadpoint_api.go @@ -12,6 +12,11 @@ import ( var _ loadpoint.API = (*Loadpoint)(nil) +// Title returns the human-readable loadpoint title +func (lp *Loadpoint) Title() string { + return lp.Title_ +} + // GetStatus returns the charging status func (lp *Loadpoint) GetStatus() api.ChargeStatus { lp.Lock() diff --git a/core/site.go b/core/site.go index df64db418..6094e3d0d 100644 --- a/core/site.go +++ b/core/site.go @@ -137,7 +137,7 @@ func NewSiteFromConfig( if serverdb.Instance != nil { var err error - if lp.db, err = db.New(lp.Title); err != nil { + if lp.db, err = db.New(lp.Title()); err != nil { return nil, err } diff --git a/hems/semp/semp.go b/hems/semp/semp.go index 728ee141c..061d32a68 100644 --- a/hems/semp/semp.go +++ b/hems/semp/semp.go @@ -377,7 +377,7 @@ func (s *SEMP) deviceInfo(id int, lp loadpoint.API) DeviceInfo { res := DeviceInfo{ Identification: Identification{ DeviceID: s.deviceID(id), - DeviceName: lp.Name(), + DeviceName: lp.Title(), DeviceType: sempCharger, DeviceSerial: s.serialNumber(id), DeviceVendor: "github.com/evcc-io/evcc", diff --git a/server/influxdb.go b/server/influxdb.go index ba5f69e52..e69ae3bfc 100644 --- a/server/influxdb.go +++ b/server/influxdb.go @@ -93,7 +93,7 @@ func (m *Influx) Run(loadPoints []loadpoint.API, in <-chan util.Param) { tags := make(map[string]string) if param.Loadpoint != nil { - tags["loadpoint"] = loadPoints[*param.Loadpoint].Name() + tags["loadpoint"] = loadPoints[*param.Loadpoint].Title() tags["vehicle"] = vehicles[*param.Loadpoint] }