evcc-io/hems/config.go
2021-12-22 11:09:00 +01:00

28 lines
631 B
Go

package hems
import (
"errors"
"strings"
"github.com/evcc-io/evcc/core"
"github.com/evcc-io/evcc/hems/ocpp"
"github.com/evcc-io/evcc/hems/semp"
"github.com/evcc-io/evcc/server"
)
// HEMS describes the HEMS system interface
type HEMS interface {
Run()
}
// NewFromConfig creates new HEMS from config
func NewFromConfig(typ string, other map[string]interface{}, site *core.Site, httpd *server.HTTPd) (HEMS, error) {
switch strings.ToLower(typ) {
case "sma", "shm", "semp":
return semp.New(other, site, httpd)
case "ocpp":
return ocpp.New(other, site)
default:
return nil, errors.New("unknown hems: " + typ)
}
}