From f5bd0e798f3eadcdf7ea05e93046207bf1f7d473 Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 17 Sep 2023 13:30:33 +0200 Subject: [PATCH] EEbus: let loadpoint rewrite currents on connection (#9921) --- charger/eebus.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/charger/eebus.go b/charger/eebus.go index 28aacac8f3..43e086c504 100644 --- a/charger/eebus.go +++ b/charger/eebus.go @@ -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 @@ -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 @@ -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 @@ -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() {