Skip to content

Commit

Permalink
EEbus: let loadpoint rewrite currents on connection (#9921)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored and naltatis committed Sep 19, 2023
1 parent 33f2306 commit f5bd0e7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion charger/eebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type EEBus struct {
expectedEnableUnpluggedState bool
current float64

// connection tracking for api.CurrentGetter
evConnected bool
currentLimit float64

lastIsChargingCheck time.Time
lastIsChargingResult bool

Expand Down Expand Up @@ -231,9 +235,15 @@ func (c *EEBus) updateState() (api.ChargeStatus, error) {

if !c.emobility.EVConnected() {
c.expectedEnableUnpluggedState = false
c.evConnected = false
return api.StatusA, nil
}

if !c.evConnected {
c.evConnected = true
c.currentLimit = -1
}

currentState, err := c.emobility.EVCurrentChargeState()
if err != nil {
return api.StatusNone, err
Expand Down Expand Up @@ -349,7 +359,11 @@ func (c *EEBus) writeCurrentLimitData(currents []float64) error {

// Set overload protection limits and self consumption limits to identical values,
// so if the EV supports self consumption it will be used automatically.
return c.emobility.EVWriteLoadControlLimits(currents, currents)
if err = c.emobility.EVWriteLoadControlLimits(currents, currents); err == nil {
c.currentLimit = currents[0]
}

return err
}

// MaxCurrent implements the api.Charger interface
Expand All @@ -374,6 +388,13 @@ func (c *EEBus) MaxCurrentMillis(current float64) error {
return nil
}

var _ api.CurrentGetter = (*Easee)(nil)

// GetMaxCurrent implements the api.CurrentGetter interface
func (c *EEBus) GetMaxCurrent() (float64, error) {
return c.currentLimit, nil
}

// CurrentPower implements the api.Meter interface
func (c *EEBus) currentPower() (float64, error) {
if !c.emobility.EVConnected() {
Expand Down

0 comments on commit f5bd0e7

Please sign in to comment.