diff --git a/cmd/root.go b/cmd/root.go index 8f48f99ad..f1f0ecc59 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -200,7 +200,7 @@ func run(cmd *cobra.Command, args []string) { // start HEMS server if conf.HEMS.Type != "" { - hems := configureHEMS(conf.HEMS, site, cache, httpd) + hems := configureHEMS(conf.HEMS, site, httpd) go hems.Run() } diff --git a/cmd/setup.go b/cmd/setup.go index 52a600d9c..9bece6170 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -143,8 +143,8 @@ func configureJavascript(conf map[string]interface{}) error { } // setup HEMS -func configureHEMS(conf typedConfig, site *core.Site, cache *util.Cache, httpd *server.HTTPd) hems.HEMS { - hems, err := hems.NewFromConfig(conf.Type, conf.Other, site, cache, httpd) +func configureHEMS(conf typedConfig, site *core.Site, httpd *server.HTTPd) hems.HEMS { + hems, err := hems.NewFromConfig(conf.Type, conf.Other, site, httpd) if err != nil { log.FATAL.Fatalf("failed configuring hems: %v", err) } diff --git a/hems/config.go b/hems/config.go index db553eb81..b9320ffdd 100644 --- a/hems/config.go +++ b/hems/config.go @@ -8,7 +8,6 @@ import ( "github.com/evcc-io/evcc/hems/ocpp" "github.com/evcc-io/evcc/hems/semp" "github.com/evcc-io/evcc/server" - "github.com/evcc-io/evcc/util" ) // HEMS describes the HEMS system interface @@ -17,12 +16,12 @@ type HEMS interface { } // NewFromConfig creates new HEMS from config -func NewFromConfig(typ string, other map[string]interface{}, site *core.Site, cache *util.Cache, httpd *server.HTTPd) (HEMS, error) { +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, cache, httpd) + return semp.New(other, site, httpd) case "ocpp": - return ocpp.New(other, site, cache) + return ocpp.New(other, site) default: return nil, errors.New("unknown hems: " + typ) } diff --git a/hems/ocpp/ocpp.go b/hems/ocpp/ocpp.go index c8745ab69..0429d6d65 100644 --- a/hems/ocpp/ocpp.go +++ b/hems/ocpp/ocpp.go @@ -19,16 +19,15 @@ import ( // OCPP is an OCPP client type OCPP struct { - log *util.Logger - cache *util.Cache - site site.API - cp ocpp16.ChargePoint + log *util.Logger + site site.API + cp ocpp16.ChargePoint } const retryTimeout = 5 * time.Second // New generates OCPP chargepoint client -func New(conf map[string]interface{}, site site.API, cache *util.Cache) (*OCPP, error) { +func New(conf map[string]interface{}, site site.API) (*OCPP, error) { cc := struct { URI string StationID string @@ -54,10 +53,9 @@ func New(conf map[string]interface{}, site site.API, cache *util.Cache) (*OCPP, cp := ocpp16.NewChargePoint(cc.StationID, nil, ws) s := &OCPP{ - log: log, - cache: cache, - site: site, - cp: cp, + log: log, + site: site, + cp: cp, } err := cp.Start(cc.URI) diff --git a/hems/semp/semp.go b/hems/semp/semp.go index 22c436a6b..3a091d890 100644 --- a/hems/semp/semp.go +++ b/hems/semp/semp.go @@ -41,7 +41,6 @@ var ( // SEMP is the SMA SEMP server type SEMP struct { log *util.Logger - cache *util.Cache closeC chan struct{} doneC chan struct{} controllable bool @@ -54,7 +53,7 @@ type SEMP struct { } // New generates SEMP Gateway listening at /semp endpoint -func New(conf map[string]interface{}, site site.API, cache *util.Cache, httpd *server.HTTPd) (*SEMP, error) { +func New(conf map[string]interface{}, site site.API, httpd *server.HTTPd) (*SEMP, error) { cc := struct { VendorID string DeviceID string @@ -91,7 +90,6 @@ func New(conf map[string]interface{}, site site.API, cache *util.Cache, httpd *s s := &SEMP{ doneC: make(chan struct{}), log: util.NewLogger("semp"), - cache: cache, site: site, uid: uid.String(), vid: cc.VendorID,