evcc-io/tariff/config.go
2021-08-21 12:53:25 +02:00

24 lines
454 B
Go

package tariff
import (
"errors"
"strings"
"github.com/evcc-io/evcc/api"
)
// NewFromConfig creates new HEMS from config
func NewFromConfig(typ string, other map[string]interface{}) (t api.Tariff, err error) {
switch strings.ToLower(typ) {
case "fixed":
t, err = NewFixed(other)
case "awattar":
t, err = NewAwattar(other)
case "tibber":
t, err = NewTibber(other)
default:
return nil, errors.New("unknown tariff: " + typ)
}
return
}