Skip to content

Commit

Permalink
Go-E: fix session energy reset on disconnect (BC) (#5119)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Nov 10, 2022
1 parent f236ba7 commit 65c11a7
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
13 changes: 5 additions & 8 deletions charger/go-e.go
Expand Up @@ -77,15 +77,12 @@ func NewGoE(uri, token string, cache time.Duration) (api.Charger, error) {
c.api = goe.NewLocal(log, util.DefaultScheme(uri, "http"), cache)
}

if !sponsor.IsAuthorized() {
return nil, api.ErrSponsorRequired
}

if c.api.IsV2() {
var phases func(int) error
if sponsor.IsAuthorized() {
phases = c.phases1p3p
} else {
log.WARN.Println("automatic 1p3p phase switching requires sponsor token")
}

return decorateGoE(c, c.totalEnergy, phases), nil
return decorateGoE(c, c.totalEnergy, c.phases1p3p), nil
}

return c, nil
Expand Down
2 changes: 2 additions & 0 deletions charger/go-e_test.go
Expand Up @@ -36,6 +36,8 @@ func TestGoEV1(t *testing.T) {
h := &handler{}
srv := httptest.NewServer(h)

sponsor.Subject = "foo"

wb, err := NewGoE(srv.URL, "", 0)
if err != nil {
t.Error(err)
Expand Down
6 changes: 5 additions & 1 deletion core/loadpoint.go
Expand Up @@ -1523,7 +1523,11 @@ func (lp *LoadPoint) updateChargeCurrents() {
// publish charged energy and duration
func (lp *LoadPoint) publishChargeProgress() {
if f, err := lp.chargeRater.ChargedEnergy(); err == nil {
lp.setChargedEnergy(1e3 * f) // convert to Wh
// workaround for Go-E resetting during disconnect, see
// https://github.com/evcc-io/evcc/issues/5092
if f > 0 {
lp.setChargedEnergy(1e3 * f) // convert to Wh
}
} else {
lp.log.ERROR.Printf("charge rater: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions templates/definition/charger/go-e-v3.yaml
Expand Up @@ -9,12 +9,13 @@ requirements:
de: |
Benötigt mindestens Firmware 052.1 oder neuer.
Für 1P/3P-Phasenumschaltung muss die HTTP API v2 im Charger aktiviert sein und es wird ein Sponsortoken benötigt. 💚
Für 1P/3P-Phasenumschaltung muss die HTTP API v2 im Charger aktiviert sein.
en: |
Requires firmware 052.1 or later.
For 1P/3P-Phase switching the HTTP API v2 in the charger setup needs to be activated and a sponsor token is required. 💚
For 1P/3P-Phase switching the HTTP API v2 in the charger setup needs to be activated.
uri: https://docs.evcc.io/docs/devices/chargers#go-echarger
evcc: ["sponsorship"]
params:
- name: host
render: |
Expand Down
1 change: 1 addition & 0 deletions templates/definition/charger/go-e.yaml
Expand Up @@ -8,6 +8,7 @@ requirements:
description:
en: Requires firmware 040.0 or later.
de: Benötigt mindestens Firmware 040.0 oder neuer.
evcc: ["sponsorship"]
params:
- name: host
render: |
Expand Down
3 changes: 2 additions & 1 deletion templates/docs/charger/go-e-v3_0.yaml
Expand Up @@ -2,10 +2,11 @@ product:
brand: go-eCharger
description: HOME+, HOMEfix (V3)
capabilities: ["1p3p", "rfid"]
requirements: ["sponsorship"]
description: |
Benötigt mindestens Firmware 052.1 oder neuer.
Für 1P/3P-Phasenumschaltung muss die HTTP API v2 im Charger aktiviert sein und es wird ein Sponsortoken benötigt. 💚
Für 1P/3P-Phasenumschaltung muss die HTTP API v2 im Charger aktiviert sein.
render:
- default: |
Expand Down
1 change: 1 addition & 0 deletions templates/docs/charger/go-e_0.yaml
Expand Up @@ -2,6 +2,7 @@ product:
brand: go-eCharger
description: HOME+, HOMEfix, Pro
capabilities: ["rfid"]
requirements: ["sponsorship"]
description: |
Benötigt mindestens Firmware 040.0 oder neuer.
render:
Expand Down

0 comments on commit 65c11a7

Please sign in to comment.