@@ -31,8 +31,8 @@ type minMax struct {
3131}
3232
3333type EEBus struct {
34- uc * eebus.UseCasesEVSE
35- ev spineapi.EntityRemoteInterface
34+ cem * eebus.CustomerEnergyManagement
35+ ev spineapi.EntityRemoteInterface
3636
3737 mux sync.RWMutex
3838 log * util.Logger
@@ -85,7 +85,7 @@ func NewEEBus(ctx context.Context, ski, ip string, hasMeter, hasChargedEnergy, v
8585 log : util .NewLogger ("eebus" ),
8686 current : 6 ,
8787 vasVW : vasVW ,
88- uc : eebus .Instance .Evse (),
88+ cem : eebus .Instance .CustomerEnergyManagement (),
8989 }
9090
9191 c .Connector = eebus .NewConnector ()
@@ -137,7 +137,7 @@ func (c *EEBus) isEvConnected() (spineapi.EntityRemoteInterface, bool) {
137137 c .mux .RLock ()
138138 defer c .mux .RUnlock ()
139139
140- return c .ev , c .ev != nil && c .uc .EvCC .EVConnected (c .ev )
140+ return c .ev , c .ev != nil && c .cem .EvCC .EVConnected (c .ev )
141141}
142142
143143// we assume that if any phase current value is > idleFactor * min Current, then charging is active and enabled is true
@@ -163,7 +163,7 @@ func (c *EEBus) isCharging(evEntity spineapi.EntityRemoteInterface) bool {
163163 }
164164
165165 if c .lp == nil {
166- limitsMin , _ , _ , err := c .uc .OpEV .CurrentLimits (evEntity )
166+ limitsMin , _ , _ , err := c .cem .OpEV .CurrentLimits (evEntity )
167167 if err != nil || len (limitsMin ) == 0 {
168168 // sometimes a min limit is not provided by the EVSE, and we can't take it from the loadpoint
169169 return false
@@ -204,7 +204,7 @@ func (c *EEBus) Status() (res api.ChargeStatus, err error) {
204204 err = c .writeCurrentLimitData (evEntity , current )
205205 }()
206206
207- currentState , err := c .uc .EvCC .ChargeState (evEntity )
207+ currentState , err := c .cem .EvCC .ChargeState (evEntity )
208208 if err != nil {
209209 return api .StatusA , nil
210210 }
@@ -235,7 +235,7 @@ func (c *EEBus) Enabled() (bool, error) {
235235
236236 // if the VW VAS PV mode is active, use PV limits
237237 if c .hasActiveVASVW (evEntity ) {
238- limits , err := c .uc .OscEV .LoadControlLimits (evEntity )
238+ limits , err := c .cem .OscEV .LoadControlLimits (evEntity )
239239 if err != nil {
240240 // there are no limits available, e.g. because the data was not received yet
241241 return c .enabled , nil
@@ -251,7 +251,7 @@ func (c *EEBus) Enabled() (bool, error) {
251251 return false , nil
252252 }
253253
254- limits , err := c .uc .OpEV .LoadControlLimits (evEntity )
254+ limits , err := c .cem .OpEV .LoadControlLimits (evEntity )
255255 if err != nil {
256256 // there are no limits available, e.g. because the data was not received yet
257257 return c .enabled , nil
@@ -282,7 +282,7 @@ func (c *EEBus) Enable(enable bool) error {
282282 // if we disable charging with a potential but not yet known communication standard ISO15118
283283 // this would set allowed A value to be 0. And this would trigger ISO connections to switch to IEC!
284284 if ! enable {
285- comStandard , err := c .uc .EvCC .CommunicationStandard (evEntity )
285+ comStandard , err := c .cem .EvCC .CommunicationStandard (evEntity )
286286 if err != nil || comStandard == evcc .EVCCCommunicationStandardUnknown {
287287 return api .ErrMustRetry
288288 }
@@ -304,11 +304,11 @@ func (c *EEBus) Enable(enable bool) error {
304304// send current charging power limits to the EV
305305func (c * EEBus ) writeCurrentLimitData (evEntity spineapi.EntityRemoteInterface , current float64 ) error {
306306 // check if the EVSE supports overload protection limits
307- if ! c .uc .OpEV .IsScenarioAvailableAtEntity (evEntity , 1 ) {
307+ if ! c .cem .OpEV .IsScenarioAvailableAtEntity (evEntity , 1 ) {
308308 return api .ErrNotAvailable
309309 }
310310
311- _ , maxLimits , _ , err := c .uc .OpEV .CurrentLimits (evEntity )
311+ _ , maxLimits , _ , err := c .cem .OpEV .CurrentLimits (evEntity )
312312 if err != nil {
313313 c .log .DEBUG .Println ("no limits from the EVSE are provided:" , err )
314314 }
@@ -342,16 +342,16 @@ func (c *EEBus) writeCurrentLimitData(evEntity spineapi.EntityRemoteInterface, c
342342
343343 // make sure the recommendations are inactive, otherwise the EV won't go to sleep
344344 // but only if it supports OSCEV and has required data!
345- if c .uc .OscEV .IsScenarioAvailableAtEntity (evEntity , 1 ) {
346- if _ , err := c .uc .OscEV .LoadControlLimits (evEntity ); err == nil {
347- if err := c .disableLimits (evEntity , c .uc .OscEV ); err != nil {
345+ if c .cem .OscEV .IsScenarioAvailableAtEntity (evEntity , 1 ) {
346+ if _ , err := c .cem .OscEV .LoadControlLimits (evEntity ); err == nil {
347+ if err := c .disableLimits (evEntity , c .cem .OscEV ); err != nil {
348348 return err
349349 }
350350 }
351351 }
352352
353353 // set overload protection limits
354- _ , err = c .uc .OpEV .WriteLoadControlLimits (evEntity , limits , nil )
354+ _ , err = c .cem .OpEV .WriteLoadControlLimits (evEntity , limits , nil )
355355 if err == nil {
356356 c .mux .Lock ()
357357 defer c .mux .Unlock ()
@@ -371,7 +371,7 @@ func (c *EEBus) hasActiveVASVW(evEntity spineapi.EntityRemoteInterface) bool {
371371 }
372372
373373 // ISO15118-2 has to be used between EVSE and EV
374- if comStandard , err := c .uc .EvCC .CommunicationStandard (evEntity ); err != nil || comStandard != model .DeviceConfigurationKeyValueStringTypeISO151182ED2 {
374+ if comStandard , err := c .cem .EvCC .CommunicationStandard (evEntity ); err != nil || comStandard != model .DeviceConfigurationKeyValueStringTypeISO151182ED2 {
375375 return false
376376 }
377377
@@ -382,7 +382,7 @@ func (c *EEBus) hasActiveVASVW(evEntity spineapi.EntityRemoteInterface) bool {
382382 }
383383
384384 // Optimization of self consumption use case support has to be available
385- if ! c .uc .EvSoc .IsScenarioAvailableAtEntity (evEntity , 1 ) {
385+ if ! c .cem .EvSoc .IsScenarioAvailableAtEntity (evEntity , 1 ) {
386386 return false
387387 }
388388
@@ -421,17 +421,17 @@ func (c *EEBus) writeLoadControlLimitsVASVW(evEntity spineapi.EntityRemoteInterf
421421 }
422422
423423 // check if the EVSE supports optimization of self consumption limits
424- if ! c .uc .OscEV .IsScenarioAvailableAtEntity (evEntity , 1 ) {
424+ if ! c .cem .OscEV .IsScenarioAvailableAtEntity (evEntity , 1 ) {
425425 return false
426426 }
427427
428428 // OSCEV requires recommendation limits to be available
429- if _ , err := c .uc .OscEV .LoadControlLimits (evEntity ); err != nil {
429+ if _ , err := c .cem .OscEV .LoadControlLimits (evEntity ); err != nil {
430430 return false
431431 }
432432
433433 // on OSCEV all limits have to be active except they are set to the default value
434- minLimits , _ , _ , err := c .uc .OscEV .CurrentLimits (evEntity )
434+ minLimits , _ , _ , err := c .cem .OscEV .CurrentLimits (evEntity )
435435 if err != nil {
436436 return false
437437 }
@@ -445,11 +445,11 @@ func (c *EEBus) writeLoadControlLimitsVASVW(evEntity spineapi.EntityRemoteInterf
445445 }
446446
447447 // set recommendation limits
448- if _ , err := c .uc .OscEV .WriteLoadControlLimits (evEntity , limits , nil ); err != nil {
448+ if _ , err := c .cem .OscEV .WriteLoadControlLimits (evEntity , limits , nil ); err != nil {
449449 return false
450450 }
451451
452- if err := c .disableLimits (evEntity , c .uc .OpEV ); err != nil {
452+ if err := c .disableLimits (evEntity , c .cem .OpEV ); err != nil {
453453 return false
454454 }
455455
@@ -515,17 +515,17 @@ func (c *EEBus) currentPower() (float64, error) {
515515
516516 // does the EVSE provide power data?
517517 var powers []float64
518- if c .uc .EvCem .IsScenarioAvailableAtEntity (evEntity , 2 ) {
518+ if c .cem .EvCem .IsScenarioAvailableAtEntity (evEntity , 2 ) {
519519 // is power data available for real? Elli Gen1 says it supports it, but doesn't provide any data
520- if powerData , err := c .uc .EvCem .PowerPerPhase (evEntity ); err == nil {
520+ if powerData , err := c .cem .EvCem .PowerPerPhase (evEntity ); err == nil {
521521 powers = powerData
522522 }
523523 }
524524
525525 // if no power data is available, and currents are reported to be supported, use currents
526- if len (powers ) == 0 && c .uc .EvCem .IsScenarioAvailableAtEntity (evEntity , 1 ) {
526+ if len (powers ) == 0 && c .cem .EvCem .IsScenarioAvailableAtEntity (evEntity , 1 ) {
527527 // no power provided, calculate from current
528- if currents , err := c .uc .EvCem .CurrentPerPhase (evEntity ); err == nil {
528+ if currents , err := c .cem .EvCem .CurrentPerPhase (evEntity ); err == nil {
529529 for _ , current := range currents {
530530 powers = append (powers , current * voltage )
531531 }
@@ -547,11 +547,11 @@ func (c *EEBus) chargedEnergy() (float64, error) {
547547 return 0 , nil
548548 }
549549
550- if ! c .uc .EvCem .IsScenarioAvailableAtEntity (evEntity , 3 ) {
550+ if ! c .cem .EvCem .IsScenarioAvailableAtEntity (evEntity , 3 ) {
551551 return 0 , api .ErrNotAvailable
552552 }
553553
554- energy , err := c .uc .EvCem .EnergyCharged (evEntity )
554+ energy , err := c .cem .EvCem .EnergyCharged (evEntity )
555555 if err != nil {
556556 return 0 , api .ErrNotAvailable
557557 }
@@ -567,7 +567,7 @@ func (c *EEBus) currents() (float64, float64, float64, error) {
567567 }
568568
569569 // check if the EVSE supports currents
570- if ! c .uc .EvCem .IsScenarioAvailableAtEntity (evEntity , 1 ) {
570+ if ! c .cem .EvCem .IsScenarioAvailableAtEntity (evEntity , 1 ) {
571571 return 0 , 0 , 0 , api .ErrNotAvailable
572572 }
573573
@@ -583,7 +583,7 @@ func (c *EEBus) currents() (float64, float64, float64, error) {
583583 return 0 , 0 , 0 , api .ErrNotAvailable
584584 }
585585
586- res , err := c .uc .EvCem .CurrentPerPhase (evEntity )
586+ res , err := c .cem .EvCem .CurrentPerPhase (evEntity )
587587 if err != nil {
588588 return 0 , 0 , 0 , eebus .WrapError (err )
589589 }
@@ -605,7 +605,7 @@ func (c *EEBus) Identify() (string, error) {
605605 return "" , nil
606606 }
607607
608- if identification , err := c .uc .EvCC .Identifications (evEntity ); err == nil && len (identification ) > 0 {
608+ if identification , err := c .cem .EvCC .Identifications (evEntity ); err == nil && len (identification ) > 0 {
609609 // return the first identification for now
610610 // later this could be multiple, e.g. MAC Address and PCID
611611 return identification [0 ].Value , nil
@@ -623,11 +623,11 @@ func (c *EEBus) Soc() (float64, error) {
623623 return 0 , api .ErrNotAvailable
624624 }
625625
626- if ! c .uc .EvSoc .IsScenarioAvailableAtEntity (evEntity , 1 ) {
626+ if ! c .cem .EvSoc .IsScenarioAvailableAtEntity (evEntity , 1 ) {
627627 return 0 , api .ErrNotAvailable
628628 }
629629
630- soc , err := c .uc .EvSoc .StateOfCharge (evEntity )
630+ soc , err := c .cem .EvSoc .StateOfCharge (evEntity )
631631 if err != nil {
632632 return 0 , api .ErrNotAvailable
633633 }
@@ -645,7 +645,7 @@ func (c *EEBus) minMax() (minMax, error) {
645645 return zero , nil
646646 }
647647
648- minLimits , maxLimits , _ , err := c .uc .OpEV .CurrentLimits (evEntity )
648+ minLimits , maxLimits , _ , err := c .cem .OpEV .CurrentLimits (evEntity )
649649 if err != nil {
650650 return zero , eebus .WrapError (err )
651651 }
0 commit comments