Skip to content

Commit

Permalink
EEBUS: Monitor measurements after limit change
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 committed Aug 28, 2024
1 parent baa6295 commit 80ec9a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 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)

limitChange time.Time // time of last limit change
lastMeasurement 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.lastMeasurement = time.Now()
}
}

Expand Down Expand Up @@ -339,6 +347,7 @@ func (c *EEBus) writeCurrentLimitData(evEntity spineapi.EntityRemoteInterface, c
}

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

return err
Expand Down Expand Up @@ -423,6 +432,7 @@ func (c *EEBus) writeLoadControlLimitsVASVW(evEntity spineapi.EntityRemoteInterf
}

// set recommendation limits
c.limitChange = time.Now()
if _, err := c.uc.OscEV.WriteLoadControlLimits(evEntity, limits, nil); err != nil {
c.log.ERROR.Println("!! OscEV.WriteLoadControlLimits:", err)
return false
Expand Down Expand Up @@ -551,6 +561,12 @@ func (c *EEBus) currents() (float64, float64, float64, error) {
return 0, 0, 0, api.ErrNotAvailable
}

// if there is no measurment data available within 15 seconds after the last limit change, return an error
if c.limitChange.After(c.lastMeasurement) && c.limitChange.Before(c.lastMeasurement.Add(15*time.Second)) {
c.log.WARN.Println("no updated measurement data available for at least 15s after limit change")
return 0, 0, 0, api.ErrNotAvailable
}

res, err := c.uc.EvCem.CurrentPerPhase(evEntity)
if err != nil {
if err == eebusapi.ErrDataNotAvailable {
Expand Down
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 80ec9a7

Please sign in to comment.