Phoenix EV-ETH: add millicurrentsupported option (#31860)

This commit is contained in:
andig 2026-07-17 09:02:29 +02:00 • committed by GitHub
parent 2dcecb25c1
commit 3a3d7ad36b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 5 deletions

View file

@ -66,19 +66,24 @@ func init() {
// NewPhoenixEVEthFromConfig creates a PhoenixEVEth charger from generic config
func NewPhoenixEVEthFromConfig(ctx context.Context, other map[string]any) (api.Charger, error) {
cc := modbus.TcpSettings{
ID: 255,
cc := struct {
modbus.TcpSettings `mapstructure:",squash"`
MilliCurrentSupported bool
}{
TcpSettings: modbus.TcpSettings{
ID: 255,
},
}
if err := util.DecodeOther(other, &cc); err != nil {
return nil, err
}
return NewPhoenixEVEth(ctx, cc.URI, cc.ID)
return NewPhoenixEVEth(ctx, cc.URI, cc.ID, cc.MilliCurrentSupported)
}
// NewPhoenixEVEth creates a PhoenixEVEth charger
func NewPhoenixEVEth(ctx context.Context, uri string, slaveID uint8) (api.Charger, error) {
func NewPhoenixEVEth(ctx context.Context, uri string, slaveID uint8, milliCurrentSupported bool) (api.Charger, error) {
conn, err := modbus.NewConnection(ctx, uri, "", "", 0, modbus.Tcp, slaveID)
if err != nil {
return nil, err
@ -110,7 +115,12 @@ func NewPhoenixEVEth(ctx context.Context, uri string, slaveID uint8) (api.Charge
}
// check presence of extended Wallbe firmware
if b, err := wb.conn.ReadHoldingRegisters(phxRegMaxCurrent, 1); err == nil && encoding.Uint16(b) >= 60 {
if !milliCurrentSupported {
b, err := wb.conn.ReadHoldingRegisters(phxRegMaxCurrent, 1)
milliCurrentSupported = err == nil && encoding.Uint16(b) >= 60
}
if milliCurrentSupported {
wb.isWallbe = true
implement.May(wb, implement.ChargerEx(wb.maxCurrentMillis))
}