cli/tariff: show db tariffs (#17494)
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
andig 2024-11-29 18:34:41 +01:00 • committed by GitHub
parent 15b69fed75
commit fe68c91554
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,18 +32,27 @@ 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 tf == nil {
continue
}
@ -53,11 +60,6 @@ func runTariff(cmd *cobra.Command, args []string) {
fmt.Println(key + ":")
}
tf, err := tariff.NewFromConfig(context.TODO(), cc.Type, cc.Other)
if err != nil {
fatal(err)
}
rates, err := tf.Rates()
if err != nil {
fatal(err)