Phoenix EV-ETH: add millicurrentsupported option (#31860)
This commit is contained in:
parent
2dcecb25c1
commit
3a3d7ad36b
2 changed files with 28 additions and 5 deletions
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue