evcc-io/tariff/types.go
TomF79 36330ac2cc
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
Solcast: limit api calls by time of day (#20696)
2025-04-22 13:50:26 +02:00

24 lines
509 B
Go

package tariff
type Typed struct {
Type string `json:"type"`
Tariff string `json:"tariff"`
Other map[string]any `mapstructure:",remain" yaml:",inline"`
}
func (t Typed) Name() string {
if t.Type == "template" {
return t.Tariff
}
return t.Type
}
type FromTo struct {
From, To int
}
func (ft FromTo) IsActive(hour int) bool {
return ft.From == 0 && ft.To == 0 ||
ft.From < ft.To && ft.From <= hour && hour <= ft.To ||
ft.From > ft.To && (ft.From <= hour || hour <= ft.To)
}