diff --git a/cmd/tariff.go b/cmd/tariff.go index 0b80cee40b..c4e949c581 100644 --- a/cmd/tariff.go +++ b/cmd/tariff.go @@ -1,13 +1,11 @@ package cmd import ( - "context" "fmt" "os" "text/tabwriter" - "github.com/evcc-io/evcc/tariff" - "github.com/evcc-io/evcc/util/config" + "github.com/evcc-io/evcc/api" "github.com/spf13/cobra" ) @@ -34,28 +32,32 @@ func runTariff(cmd *cobra.Command, args []string) { fatal(err) } + tariffs, err := configureTariffs(conf.Tariffs) + if err != nil { + fatal(err) + } + var name string if len(args) == 1 { name = args[0] } - for key, cc := range map[string]config.Typed{ - "grid": conf.Tariffs.Grid, - "feedin": conf.Tariffs.FeedIn, - "co2": conf.Tariffs.Co2, - "planner": conf.Tariffs.Planner, + for key, tf := range map[string]api.Tariff{ + "grid": tariffs.Grid, + "feedin": tariffs.FeedIn, + "co2": tariffs.Co2, + "planner": tariffs.Planner, } { - if cc.Type == "" || (name != "" && key != name) { + if name != "" && key != name { continue } - if name == "" { - fmt.Println(key + ":") + if tf == nil { + continue } - tf, err := tariff.NewFromConfig(context.TODO(), cc.Type, cc.Other) - if err != nil { - fatal(err) + if name == "" { + fmt.Println(key + ":") } rates, err := tf.Rates()