Skip to content

Commit

Permalink
cli/tariff: show db tariffs (#17494)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Nov 29, 2024
1 parent 15b69fe commit fe68c91
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions cmd/tariff.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand All @@ -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()
Expand Down

0 comments on commit fe68c91

Please sign in to comment.