Prepare for removing deprecated type identifier (#2685)
This commit is contained in:
parent
fe0478ff43
commit
5ce7be45bb
4 changed files with 32 additions and 0 deletions
|
|
@ -27,6 +27,13 @@ func NewConfigurableFromConfig(other map[string]interface{}) (api.Charger, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// TODO deprecate
|
||||
log := util.NewLogger("charger")
|
||||
cc.Status.Deprecate(log)
|
||||
cc.Enable.Deprecate(log)
|
||||
cc.Enabled.Deprecate(log)
|
||||
cc.MaxCurrent.Deprecate(log)
|
||||
|
||||
status, err := provider.NewStringGetterFromConfig(cc.Status)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("status: %w", err)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,15 @@ func NewConfigurableFromConfig(other map[string]interface{}) (api.Meter, error)
|
|||
return nil, fmt.Errorf("power: %w", err)
|
||||
}
|
||||
|
||||
// TODO deprecate
|
||||
log := util.NewLogger("meter")
|
||||
cc.Power.Deprecate(log)
|
||||
cc.Energy.Deprecate(log)
|
||||
cc.SoC.Deprecate(log)
|
||||
for _, p := range cc.Currents {
|
||||
p.Deprecate(log)
|
||||
}
|
||||
|
||||
m, _ := NewConfigurable(power)
|
||||
|
||||
// decorate Meter with MeterEnergy
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package provider
|
|||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/evcc-io/evcc/util"
|
||||
)
|
||||
|
||||
// provider types
|
||||
|
|
@ -56,6 +58,13 @@ type Config struct {
|
|||
Other map[string]interface{} `mapstructure:",remain"`
|
||||
}
|
||||
|
||||
// TODO prepare for removing deprecated type attribute
|
||||
func (c *Config) Deprecate(log *util.Logger) {
|
||||
if c != nil && c.Type != "" {
|
||||
log.WARN.Printf("type:%s is deprecated, use source:%s instead", c.Type, c.Type)
|
||||
}
|
||||
}
|
||||
|
||||
// PluginType returns the plugin type in a legacy-aware way
|
||||
func (c Config) PluginType() string {
|
||||
typ := c.Source
|
||||
|
|
|
|||
|
|
@ -36,6 +36,13 @@ func NewConfigurableFromConfig(other map[string]interface{}) (api.Vehicle, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// TODO deprecate
|
||||
log := util.NewLogger("vehicle")
|
||||
cc.Soc.Deprecate(log)
|
||||
cc.Status.Deprecate(log)
|
||||
cc.Range.Deprecate(log)
|
||||
cc.Odometer.Deprecate(log)
|
||||
|
||||
if cc.Cache != nil {
|
||||
util.NewLogger("vehicle").WARN.Println("cache is deprecated and will be removed in a future release")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue