evcc-io/hems/config.go
andig acb521362a
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
EEBus: use context (#19284)
2025-03-01 12:12:56 +01:00

32 lines
764 B
Go

package hems
import (
"context"
"errors"
"strings"
"github.com/evcc-io/evcc/core/site"
"github.com/evcc-io/evcc/hems/eebus"
"github.com/evcc-io/evcc/hems/relay"
"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(ctx context.Context, typ string, other map[string]interface{}, site site.API, httpd *server.HTTPd) (HEMS, error) {
switch strings.ToLower(typ) {
case "sma", "shm", "semp":
return semp.New(other, site, httpd)
case "eebus":
return eebus.New(ctx, other, site)
case "relay":
return relay.New(ctx, other, site)
default:
return nil, errors.New("unknown hems: " + typ)
}
}