Prepare for removing deprecated type identifier (#2685)

This commit is contained in:
andig 2022-02-23 14:28:53 +01:00 • committed by GitHub
parent fe0478ff43
commit 5ce7be45bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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