Skip to content

Commit

Permalink
Charger: remove unhandled status D, E, F (#17956)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Dec 30, 2024
1 parent db60ef5 commit 5440142
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 127 deletions.
2 changes: 0 additions & 2 deletions api/chargemodestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const (
StatusA ChargeStatus = "A" // Fzg. angeschlossen: nein Laden aktiv: nein Ladestation betriebsbereit, Fahrzeug getrennt
StatusB ChargeStatus = "B" // Fzg. angeschlossen: ja Laden aktiv: nein Fahrzeug verbunden, Netzspannung liegt nicht an
StatusC ChargeStatus = "C" // Fzg. angeschlossen: ja Laden aktiv: ja Fahrzeug lädt, Netzspannung liegt an
StatusD ChargeStatus = "D" // Fzg. angeschlossen: ja Laden aktiv: ja Fahrzeug lädt mit externer Belüfungsanforderung (für Blei-Säure-Batterien)
StatusE ChargeStatus = "E" // Fzg. angeschlossen: ja Laden aktiv: nein Fehler Fahrzeug / Kabel (CP-Kurzschluss, 0V)
StatusF ChargeStatus = "F" // Fzg. angeschlossen: ja Laden aktiv: nein Fehler EVSE oder Abstecken simulieren (CP-Wake-up, -12V)
)

var StatusEasA = map[ChargeStatus]ChargeStatus{StatusE: StatusA}
Expand Down
6 changes: 1 addition & 5 deletions charger/amperfied.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ func (wb *Amperfied) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 6, 7:
return api.StatusC, nil
case 8:
return api.StatusD, nil
case 9:
return api.StatusE, nil
case 10:
// ensure RemoteLock is disabled after wake-up
b, err := wb.conn.ReadHoldingRegisters(ampRegRemoteLock, 1)
Expand All @@ -183,7 +179,7 @@ func (wb *Amperfied) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
}

return api.StatusF, nil
fallthrough
default:
return api.StatusNone, fmt.Errorf("invalid status: %d", sb)
}
Expand Down
10 changes: 2 additions & 8 deletions charger/cfos.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package charger

import (
"encoding/binary"
"errors"
"fmt"

"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
Expand Down Expand Up @@ -114,14 +114,8 @@ func (wb *CfosPowerBrain) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 2: // laden
return api.StatusC, nil
case 3: // laden mit Kühlung
return api.StatusD, nil
case 4: // kein Strom
return api.StatusE, nil
case 5: // Fehler
return api.StatusF, nil
default:
return api.StatusNone, errors.New("invalid response")
return api.StatusNone, fmt.Errorf("invalid status: %d", b[1])
}
}

Expand Down
9 changes: 2 additions & 7 deletions charger/dadapower.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package charger
import (
"context"
"encoding/binary"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -107,19 +106,15 @@ func (wb *Dadapower) Status() (api.ChargeStatus, error) {
return api.StatusNone, err
}

switch binary.BigEndian.Uint16(b) {
switch status := binary.BigEndian.Uint16(b); status {
case 0x0A: // ready
return api.StatusA, nil
case 0x0B: // EV is present
return api.StatusB, nil
case 0x0C: // charging
return api.StatusC, nil
case 0x0D: // charging with ventilation
return api.StatusD, nil
case 0x0E: // failure (e.g. diode check, RCD failure)
return api.StatusE, nil
default:
return api.StatusNone, errors.New("invalid response")
return api.StatusNone, fmt.Errorf("invalid status: %d", status)
}
}

Expand Down
2 changes: 0 additions & 2 deletions charger/daheimladen.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ func (c *DaheimLaden) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case daheimladen.CHARGING, daheimladen.FINISHING:
return api.StatusC, nil
case daheimladen.FAULTED:
return api.StatusF, nil
default:
return api.StatusNone, fmt.Errorf("invalid status: %s", res.Status)
}
Expand Down
4 changes: 1 addition & 3 deletions charger/eebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,8 @@ func (c *EEBus) Status() (res api.ChargeStatus, err error) {
return api.StatusC, nil
}
return api.StatusB, nil
case ucapi.EVChargeStateTypeError: // Error
return api.StatusF, nil
default:
return api.StatusNone, fmt.Errorf("properties unknown result: %s", currentState)
return api.StatusNone, fmt.Errorf("invalid status: %s", currentState)
}
}

Expand Down
4 changes: 1 addition & 3 deletions charger/em2go.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ func (wb *Em2Go) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 4, 6:
return api.StatusC, nil
case 5, 7:
return api.StatusF, nil
default:
return api.StatusNone, fmt.Errorf("invalid status: %0x", b[1])
return api.StatusNone, fmt.Errorf("invalid status: %d", b[1])
}
}

Expand Down
8 changes: 2 additions & 6 deletions charger/evsedin.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package charger

import (
"errors"
"fmt"
"time"

"github.com/evcc-io/evcc/api"
Expand Down Expand Up @@ -76,12 +76,8 @@ func (evse *EvseDIN) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 3: // charging
return api.StatusC, nil
case 4: // charging with ventilation
return api.StatusD, nil
case 5: // failure (e.g. diode check, RCD failure)
return api.StatusE, nil
default:
return api.StatusNone, errors.New("invalid response")
return api.StatusNone, fmt.Errorf("invalid status: %d", b[1])
}
}

Expand Down
6 changes: 1 addition & 5 deletions charger/evsewifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,8 @@ func (wb *EVSEWifi) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 3: // charging
return api.StatusC, nil
case 4: // charging with ventilation
return api.StatusD, nil
case 5: // failure (e.g. diode check, RCD failure)
return api.StatusE, nil
default:
return api.StatusNone, errors.New("invalid response")
return api.StatusNone, fmt.Errorf("invalid status: %d", params.VehicleState)
}
}

Expand Down
6 changes: 1 addition & 5 deletions charger/heidelberg-ec.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ func (wb *HeidelbergEC) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 6, 7:
return api.StatusC, nil
case 8:
return api.StatusD, nil
case 9:
return api.StatusE, nil
case 10:
// ensure RemoteLock is disabled after wake-up
b, err := wb.conn.ReadHoldingRegisters(hecRegRemoteLock, 1)
Expand All @@ -180,7 +176,7 @@ func (wb *HeidelbergEC) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
}

return api.StatusF, nil
fallthrough
default:
return api.StatusNone, fmt.Errorf("invalid status: %d", sb)
}
Expand Down
8 changes: 2 additions & 6 deletions charger/kse.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,15 @@ func (wb *KSE) Status() (api.ChargeStatus, error) {
return api.StatusNone, err
}

s := binary.BigEndian.Uint16(b)

switch s {
switch status := binary.BigEndian.Uint16(b); status {
case 0, 1, 3:
return api.StatusA, nil
case 4:
return api.StatusB, nil
case 5:
return api.StatusC, nil
case 6, 7, 8:
return api.StatusE, nil
default:
return api.StatusNone, fmt.Errorf("invalid status: %d", s)
return api.StatusNone, fmt.Errorf("invalid status: %d", status)
}
}

Expand Down
6 changes: 2 additions & 4 deletions charger/mennekes-hcc3.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,15 @@ func (wb *MennekesHcc3) Status() (api.ChargeStatus, error) {
return api.StatusNone, err
}

switch binary.BigEndian.Uint16(b) {
switch status := binary.BigEndian.Uint16(b); status {
case 1, 2:
return api.StatusA, nil
case 3, 4:
return api.StatusB, nil
case 5, 6:
return api.StatusC, nil
case 7, 8:
return api.StatusD, nil
default:
return api.StatusNone, fmt.Errorf("invalid status: %0x", b[1])
return api.StatusNone, fmt.Errorf("invalid status: %d", status)
}
}

Expand Down
6 changes: 3 additions & 3 deletions charger/nrgble_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (wb *NRGKickBLE) mergeSettings(info ble.Info) ble.Settings {
func (wb *NRGKickBLE) Status() (api.ChargeStatus, error) {
var res ble.Power
if err := wb.read(ble.PowerService, &res); err != nil {
return api.StatusF, err
return api.StatusNone, err
}

wb.log.TRACE.Printf("read power: %+v", res)
Expand All @@ -226,9 +226,9 @@ func (wb *NRGKickBLE) Status() (api.ChargeStatus, error) {
return api.StatusC, nil
case 4:
return api.StatusA, nil
default:
return api.StatusNone, fmt.Errorf("invalid status: %d", res.CPSignal)
}

return api.StatusA, fmt.Errorf("unexpected cp signal: %d", res.CPSignal)
}

// Enabled implements the api.Charger interface
Expand Down
4 changes: 2 additions & 2 deletions charger/nrggen2.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ func (nrg *NRGKickGen2) Status() (api.ChargeStatus, error) {
if err != nil {
return api.StatusNone, err
}
return api.StatusF, fmt.Errorf("%d", binary.BigEndian.Uint16(b))
return api.StatusNone, fmt.Errorf("charger error: %d", binary.BigEndian.Uint16(b))
case 7:
return api.StatusB, nil
default:
return api.StatusNone, fmt.Errorf("unhandled status type")
return api.StatusNone, fmt.Errorf("invalid status: %d", status)
}
}

Expand Down
6 changes: 1 addition & 5 deletions charger/ocpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,8 @@ func (c *OCPP) Status() (api.ChargeStatus, error) {
case
core.ChargePointStatusCharging: // "Charging"
return api.StatusC, nil
case
core.ChargePointStatusReserved, // "Reserved"
core.ChargePointStatusFaulted: // "Faulted"
return api.StatusF, fmt.Errorf("chargepoint status: %s", status)
default:
return api.StatusNone, fmt.Errorf("invalid chargepoint status: %s", status)
return api.StatusNone, fmt.Errorf("invalid status: %s", status)
}
}

Expand Down
20 changes: 10 additions & 10 deletions charger/openevse.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func (c *OpenEVSE) hasPhaseSwitchCapabilities() error {
// Status implements the api.Charger interface
func (c *OpenEVSE) Status() (api.ChargeStatus, error) {
res, err := c.statusG.Get()
if err != nil {
return api.StatusNone, err
}

/*
0: "unknown",
1: "not connected",
Expand All @@ -154,22 +158,18 @@ func (c *OpenEVSE) Status() (api.ChargeStatus, error) {
255: "disabled"
*/

switch state := res.State; state {
switch res.State {
case 1:
return api.StatusA, err
return api.StatusA, nil
case 2, 254, 255:
if res.Vehicle == 1 {
return api.StatusB, err
return api.StatusB, nil
}
return api.StatusA, err
return api.StatusA, nil
case 3:
return api.StatusC, err
case 4:
return api.StatusD, err
case 5, 6, 7, 8, 9, 10, 11:
return api.StatusF, err
return api.StatusC, nil
default:
return api.StatusNone, fmt.Errorf("unknown EVSE state: %d", state)
return api.StatusNone, fmt.Errorf("invalid status: %d", res.State)
}
}

Expand Down
39 changes: 8 additions & 31 deletions charger/pcelectric.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,48 +119,25 @@ func (wb *PCElectric) Status() (api.ChargeStatus, error) {
}
wb.log.DEBUG.Printf("chargeStatus: %d", chargeStatus)

var res api.ChargeStatus
switch chargeStatus {
case 0x00, 0x10: // notconnected
res = api.StatusA
return api.StatusA, nil
case 0x30: // connected
res = api.StatusB
return api.StatusB, nil
case 0x40: // charging
res = api.StatusC
return api.StatusC, nil
case 0x42, // chargepaused
0x50, // chargefinished
0x60: // chargecancelled
res = api.StatusB
return api.StatusB, nil
case 0x90: // unavailable
if sessionStartTime > 0 {
res = api.StatusB
} else {
res = api.StatusF
return api.StatusB, nil
}
case 0x95, // dcfault
0x96, // dchardwarefault
0x9A, // cpfault
0x9B: // cpshorted
res = api.StatusE
case 0x70, // overheat
0x80, // criticaltemperature
0x91, // reserved
0x9C, // remotedisabled
0x9D, // dlmfault
0xA0, // cablefault
0xA1,
0xA2, // lockingfault
0xA3,
0xA4, // contactorfault
0xA8, // rcdfault
0xF0, // wait
0xF1: // ventfault
res = api.StatusF
default: // generalfault
res = api.StatusF
fallthrough
default:
return api.StatusNone, fmt.Errorf("invalid status: %d", chargeStatus)
}

return res, nil
}

// Enabled implements the api.Charger interface
Expand Down
2 changes: 1 addition & 1 deletion charger/sgready.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (wb *SgReady) Status() (api.ChargeStatus, error) {
}

if mode == Stop {
return api.StatusE, errors.New("stop mode")
return api.StatusNone, errors.New("stop mode")
}

status := map[int64]api.ChargeStatus{Boost: api.StatusC, Normal: api.StatusB}[mode]
Expand Down
8 changes: 1 addition & 7 deletions charger/smartevse.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,8 @@ func (wb *smartEVSE) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 3:
return api.StatusC, nil
case 4:
return api.StatusD, nil
case 5:
return api.StatusE, nil
case 6:
return api.StatusF, nil
default:
return api.StatusNone, fmt.Errorf("invalid status returned: %d", status)
return api.StatusNone, fmt.Errorf("invalid status: %d", status)
}
}

Expand Down
4 changes: 0 additions & 4 deletions charger/solax.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ func (wb *Solax) Status() (api.ChargeStatus, error) {
return api.StatusB, nil
case 2: // "Charging"
return api.StatusC, nil
case
6, // "Reserved"
4: // "Faulted"
return api.StatusF, nil
default:
return api.StatusNone, fmt.Errorf("invalid status: %d", s)
}
Expand Down
Loading

0 comments on commit 5440142

Please sign in to comment.