Support Wallbe chargers with Phoenix EV-CC-AC1-M3-CBC-RCM-ETH controllers (#56)

This commit is contained in:
andig 2020-04-26 17:30:51 +02:00
parent a1bb0dc594
commit 2c23dfd985
5 changed files with 46 additions and 17 deletions

View file

@ -7,7 +7,7 @@ EVCC is an extensible EV Charge Controller with PV integration implemented in [G
## Features
- simple and clean user interface
- multiple [chargers](#charger): Wallbe (tested with Wallbe Eco S), Phoenix controllers (EV-CC-AC1-M3-CBC-RCM), go-eCharger, openWB slave, Mobile Charger Connect (currently used by Porsche), any other charger using scripting
- multiple [chargers](#charger): Wallbe (tested with Wallbe Eco S), Phoenix controllers (EM-CP-PP-ETH), go-eCharger, openWB slave, Mobile Charger Connect (currently used by Porsche), any other charger using scripting
- more chargers experimentally supported: NRGKick, SimpleEVSE, EVSEWifi
- different [vehicles](#vehicle) to show battery status: Audi (eTron), BMW (i3), Tesla, Nissan (Leaf), any other vehicle using scripting
- [plugins](#plugins) for integrating with hardware devices and home automation: Modbus (meters and grid inverters), MQTT and shell scripts
@ -128,8 +128,8 @@ Optionally, charger can also provide:
Available charger implementations are:
- `wallbe`: Wallbe Eco chargers (see [Hardware Preparation](#Wallbe-hardware-preparation) for preparing the Wallbe)
- `phoenix`: chargers with Phoenix controllers
- `wallbe`: Wallbe Eco chargers (see [Hardware Preparation](#Wallbe-hardware-preparation) for preparing the Wallbe). For older Wallbe boxes (pre 2019) with Phoenix EV-CC-AC1-M3-CBC-RCM-ETH controllers make sure to set `legacy: true` to enable correct current configuration.
- `phoenix`: chargers with Phoenix EM-CP-PP-ETH controllers
- `simpleevse`: chargers with SimpleEVSE controllers connected via ModBus (e.g. OpenWB)
- `evsewifi`: chargers with SimpleEVSE controllers using [SimpleEVSE-Wifi](https://github.com/CurtRod/SimpleEVSE-WiFi)
- `nrgkick`: NRGKick chargers with Connect module
@ -147,7 +147,7 @@ To allow controlling charge start/stop, the Wallbe physical configuration must b
More information on interacting with Wallbe chargers can be found at [GoingElectric](https://www.goingelectric.de/forum/viewtopic.php?p=1212583). Use with care.
**NOTE:** The Wallbe products come in two flavors. Older models (2017 known to be "old", 2019 known to be "new") use the Phoenix EV-CC-AC1-M3-CBC-RCM controller. For such models make sure to use `phoenix` charger type instead of `wallbe`. You can find you which one you have using [MBMD](5):
**NOTE:** The Wallbe products come in two flavors. Older models (2017 known to be "old", 2019 known to be "new") use the Phoenix EV-CC-AC1-M3-CBC-RCM controller. For such models make sure to set `legacy: true`. You can find you which one you have using [MBMD](5):
```sh
mbmd read -a 192.168.0.8:502 -d 255 -t holding -e int 300 1

View file

@ -15,7 +15,7 @@ const (
phRegEnable = 400 // Coil
)
// Phoenix is an api.ChargeController implementation for Phoenix wallboxes.
// Phoenix is an api.ChargeController implementation for Phoenix EM-CP-PP-ETH wallboxes.
// It uses Modbus TCP to communicate with the wallbox at modbus client id 255.
type Phoenix struct {
log *api.Logger

View file

@ -12,36 +12,46 @@ import (
const (
slaveID = 255
wbRegStatus = 100 // Input
wbRegChargeTime = 102 // Input
wbRegActualCurrent = 300 // Holding
wbRegEnable = 400 // Coil
wbRegOverchargeProtect = 409 // Coil
wbRegReset = 413 // Coil
wbRegMaxCurrent = 528 // Holding
wbRegStatus = 100 // Input
wbRegChargeTime = 102 // Input
wbRegActualCurrent = 300 // Holding
wbRegEnable = 400 // Coil
wbRegMaxCurrent = 528 // Holding
timeout = 1 * time.Second
protocolTimeout = 2 * time.Second
)
// Wallbe is an api.ChargeController implementation for Wallbe wallboxes.
// It supports both wallbe controllers (post 2019 models) and older ones using the
// Phoenix EV-CC-AC1-M3-CBC-RCM-ETH controller.
// It uses Modbus TCP to communicate with the wallbox at modbus client id 255.
type Wallbe struct {
log *api.Logger
client modbus.Client
handler *modbus.TCPClientHandler
factor int64
}
// NewWallbeFromConfig creates a Wallbe charger from generic config
func NewWallbeFromConfig(log *api.Logger, other map[string]interface{}) api.Charger {
cc := struct{ URI string }{}
func NewWallbeFromConfig(log *api.Logger, other map[string]interface{}) *Wallbe {
cc := struct {
URI string
Legacy bool
}{}
api.DecodeOther(log, other, &cc)
return NewWallbe(cc.URI)
wb := NewWallbe(cc.URI)
if cc.Legacy {
wb.factor = 1
}
return wb
}
// NewWallbe creates a Wallbe charger
func NewWallbe(conn string) api.Charger {
func NewWallbe(conn string) *Wallbe {
if conn == "" {
conn = "192.168.0.8:502"
}
@ -57,6 +67,7 @@ func NewWallbe(conn string) api.Charger {
log: api.NewLogger("wlbe"),
client: client,
handler: handler,
factor: 10,
}
// wb.showIOs()
@ -154,7 +165,7 @@ func (wb *Wallbe) MaxCurrent(current int64) error {
return fmt.Errorf("invalid current %d", current)
}
u := uint16(current * 10)
u := uint16(current * wb.factor)
b, err := wb.client.WriteSingleRegister(wbRegMaxCurrent, u)
wb.log.TRACE.Printf("write max current %d %0X: %0 X", wbRegMaxCurrent, u, b)

17
charger/wallbe_test.go Normal file
View file

@ -0,0 +1,17 @@
package charger
import "testing"
func TestWallbe(t *testing.T) {
wb := NewWallbeFromConfig(nil, nil)
if wb.factor != 10 {
t.Errorf("invalid factor: %d", wb.factor)
}
wb = NewWallbeFromConfig(nil, map[string]interface{}{"legacy": true})
if wb.factor != 1 {
t.Errorf("invalid factor: %d", wb.factor)
}
}

View file

@ -66,6 +66,7 @@ chargers:
- name: wallbe
type: wallbe # Wallbe charger
uri: 192.168.0.8:502 # ModBus address
# legacy: true # enable for older Wallbes with Phoenix EV-CC-AC1-M3-CBC-RCM controller
- name: phoenix
type: phoenix # Charger with Phoenix Contact controller
uri: 192.168.0.8:502 # ModBus address