Skip to content

Commit

Permalink
EEbus: Monitor measurements after limit change (#15778)
Browse files Browse the repository at this point in the history
If a limit has been set, a measurement is expected to provided within 15s. If this is not the case, then show a warning and return an error.

Also add support for the Elli Connect Pro internal meter again.

This should now lead to those EEBUS wallboxes not providing measurements, to fall back to the actual limit being assumed as being the current measurement. And the user is informed about non function metering in the wallbox.
  • Loading branch information
DerAndereAndi authored Sep 1, 2024
1 parent 3c359fc commit ad0f547
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
31 changes: 23 additions & 8 deletions charger/eebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
eebusapi "github.com/enbility/eebus-go/api"
ucapi "github.com/enbility/eebus-go/usecases/api"
"github.com/enbility/eebus-go/usecases/cem/evcc"
"github.com/enbility/eebus-go/usecases/cem/evcem"
spineapi "github.com/enbility/spine-go/api"
"github.com/enbility/spine-go/model"
"github.com/evcc-io/evcc/api"
Expand Down Expand Up @@ -38,6 +39,9 @@ type EEBus struct {
lp loadpoint.API
minMaxG func() (minMax, error)

limitUpdated time.Time // time of last limit change
currentsUpdated time.Time // time of last measurement

vasVW bool // wether the EVSE supports VW VAS with ISO15118-2
enabled bool
reconnect bool
Expand Down Expand Up @@ -121,6 +125,10 @@ func (c *EEBus) UseCaseEvent(device spineapi.DeviceRemoteInterface, entity spine

case evcc.EvDisconnected:
c.ev = nil

case evcem.DataUpdateCurrentPerPhase:
// do not use the timestamp of the measurement itself, as some devices don't provide it
c.currentsUpdated = time.Now()
}
}

Expand Down Expand Up @@ -330,6 +338,7 @@ func (c *EEBus) writeCurrentLimitData(evEntity spineapi.EntityRemoteInterface, c
// if VAS VW is available, limits are completely covered by it
// this way evcc can fully control the charging behaviour
if c.writeLoadControlLimitsVASVW(evEntity, limits) {
c.limitUpdated = time.Now()
return nil
}

Expand All @@ -340,6 +349,9 @@ func (c *EEBus) writeCurrentLimitData(evEntity spineapi.EntityRemoteInterface, c

// set overload protection limits
_, err = c.uc.OpEV.WriteLoadControlLimits(evEntity, limits, nil)
if err == nil {
c.limitUpdated = time.Now()
}

return err
}
Expand Down Expand Up @@ -551,12 +563,18 @@ func (c *EEBus) currents() (float64, float64, float64, error) {
return 0, 0, 0, api.ErrNotAvailable
}

c.mux.Lock()
ts := c.currentsUpdated
c.mux.Unlock()

// if there is no measurement data available within 15 seconds after the last limit change, return an error
if d := ts.Sub(c.limitUpdated); d < 0 || d > 15*time.Second {
return 0, 0, 0, api.ErrNotAvailable
}

res, err := c.uc.EvCem.CurrentPerPhase(evEntity)
if err != nil {
if err == eebusapi.ErrDataNotAvailable {
err = api.ErrNotAvailable
}
return 0, 0, 0, err
return 0, 0, 0, eebus.WrapError(err)
}

// fill phases
Expand Down Expand Up @@ -618,10 +636,7 @@ func (c *EEBus) minMax() (minMax, error) {

minLimits, maxLimits, _, err := c.uc.OpEV.CurrentLimits(evEntity)
if err != nil {
if err == eebusapi.ErrDataNotAvailable {
err = api.ErrNotAvailable
}
return zero, err
return zero, eebus.WrapError(err)
}

if len(minLimits) == 0 || len(maxLimits) == 0 {
Expand Down
15 changes: 15 additions & 0 deletions server/eebus/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package eebus

import (
"errors"

eebusapi "github.com/enbility/eebus-go/api"
"github.com/evcc-io/evcc/api"
)

func WrapError(err error) error {
if errors.Is(err, eebusapi.ErrDataNotAvailable) {
return api.ErrNotAvailable
}
return err
}
2 changes: 2 additions & 0 deletions templates/definition/charger/elli-charger-pro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ params:
- name: ip
render: |
{{ include "eebus" . }}
meter: true
chargedEnergy: false

0 comments on commit ad0f547

Please sign in to comment.