Config UI: add tariffs (#26698)
Co-authored-by: Maschga <88616799+Maschga@users.noreply.github.com> Co-authored-by: andig <cpuidle@gmail.com> Co-authored-by: andig <andi@evcc.io>
This commit is contained in:
parent
ba159992fd
commit
a4ed1080e1
55 changed files with 2711 additions and 310 deletions
|
|
@ -2,6 +2,7 @@ package globalconfig
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"iter"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
|
|
@ -173,6 +174,34 @@ type Tariffs struct {
|
|||
Solar []config.Typed
|
||||
}
|
||||
|
||||
func (c Tariffs) IsConfigured() bool {
|
||||
return c.Currency != "" || c.Grid.Type != "" || c.FeedIn.Type != "" || c.Co2.Type != "" || c.Planner.Type != "" || len(c.Solar) > 0
|
||||
}
|
||||
|
||||
type TariffRefs struct {
|
||||
Grid string `json:"grid"`
|
||||
FeedIn string `json:"feedIn"`
|
||||
Co2 string `json:"co2"`
|
||||
Planner string `json:"planner"`
|
||||
Solar []string `json:"solar"`
|
||||
}
|
||||
|
||||
func (refs TariffRefs) IsConfigured() bool {
|
||||
return refs.Grid != "" || refs.FeedIn != "" || refs.Co2 != "" || refs.Planner != "" || len(refs.Solar) > 0
|
||||
}
|
||||
|
||||
func (refs TariffRefs) Used() iter.Seq[string] {
|
||||
return func(yield func(string) bool) {
|
||||
for _, ref := range append([]string{refs.Grid, refs.FeedIn, refs.Co2, refs.Planner}, refs.Solar...) {
|
||||
if ref != "" {
|
||||
if !yield(ref) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Network struct {
|
||||
Schema_ string `json:"schema,omitempty" mapstructure:"schema"` // TODO deprecated
|
||||
ExternalUrl string `json:"externalUrl"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue