Skip to content

Commit

Permalink
Add solar type
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 19, 2025
1 parent 280d051 commit d54f9eb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/tariff.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ const (
TariffTypePriceDynamic
TariffTypePriceForecast
TariffTypeCo2
TariffTypeSolar
)
12 changes: 8 additions & 4 deletions api/tarifftype_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion cmd/tariff.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,20 @@ func runTariff(cmd *cobra.Command, args []string) {
fatal(err)
}

unit := "Price/Cost"
switch tf.Type() {
case api.TariffTypeCo2:
unit += "Footprint (gCO2/kWh)"
case api.TariffTypeSolar:
unit = "Yield (W)"
default:
if c := conf.Tariffs.Currency; c != "" {
unit += fmt.Sprintf(" (%s/kWh)", c)
}
}

tw := tabwriter.NewWriter(os.Stdout, 0, 0, 4, ' ', 0)
fmt.Fprintln(tw, "From\tTo\tPrice/Cost")
fmt.Fprintln(tw, "From\tTo\t"+unit)
const format = "2006-01-02 15:04:05"

for _, r := range rates {
Expand Down
1 change: 1 addition & 0 deletions templates/definition/tariff/forecast-solar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ params:
- name: apikey
render: |
type: custom
tariff: solar
forecast:
source: http
uri: https://api.forecast.solar/{{ if .apikey }}{{ .apikey }}/{{ end }}estimate/{{ .lat }}/{{ .lon }}/{{ .dec }}/{{ .az }}/{{ .kwp }}
Expand Down

0 comments on commit d54f9eb

Please sign in to comment.