EEbus: let loadpoint rewrite currents on connection (#9921)

This commit is contained in:
andig 2023-09-17 13:30:33 +02:00 • committed by GitHub
parent 576a680aee
commit cc1e21bea7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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() {