Delta AC MAX: fix status (#15963)
This commit is contained in:
parent
9a0d6506f4
commit
efc7412ceb
1 changed files with 33 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ type Delta struct {
|
|||
curr float64
|
||||
base uint16
|
||||
enabled bool
|
||||
isBasic bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -101,6 +102,11 @@ func NewDelta(uri, device, comset string, baudrate int, proto modbus.Protocol, s
|
|||
|
||||
wb.base = connector * 1000
|
||||
|
||||
// check for basic or smart register set
|
||||
if _, err := wb.conn.ReadInputRegisters(wb.base+deltaRegEvseChargerState, 1); err != nil {
|
||||
wb.isBasic = true
|
||||
}
|
||||
|
||||
b, err := wb.conn.ReadHoldingRegisters(deltaRegCommunicationTimeoutEnabled, 1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failsafe timeout enabled: %w", err)
|
||||
|
|
@ -153,7 +159,12 @@ func (wb *Delta) Status() (api.ChargeStatus, error) {
|
|||
switch s := encoding.Uint16(b); s {
|
||||
case 0, 1, 2:
|
||||
return api.StatusA, nil
|
||||
case 3, 5, 6, 7, 9:
|
||||
case 3:
|
||||
if wb.isBasic {
|
||||
return api.StatusA, nil
|
||||
}
|
||||
return api.StatusB, nil
|
||||
case 5, 6, 7, 9:
|
||||
return api.StatusB, nil
|
||||
case 4:
|
||||
return api.StatusC, nil
|
||||
|
|
@ -162,6 +173,27 @@ func (wb *Delta) Status() (api.ChargeStatus, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var _ api.StatusReasoner = (*Delta)(nil)
|
||||
|
||||
// statusReason implements the api.StatusReasoner interface
|
||||
func (wb *Delta) StatusReason() (api.Reason, error) {
|
||||
if !wb.isBasic {
|
||||
b, err := wb.conn.ReadInputRegisters(wb.base+deltaRegEvseState, 1)
|
||||
if err != nil {
|
||||
return api.ReasonUnknown, err
|
||||
}
|
||||
|
||||
switch s := encoding.Uint16(b); s {
|
||||
case 3:
|
||||
return api.ReasonWaitingForAuthorization, nil
|
||||
case 5:
|
||||
return api.ReasonDisconnectRequired, nil
|
||||
}
|
||||
}
|
||||
|
||||
return api.ReasonUnknown, nil
|
||||
}
|
||||
|
||||
// Enabled implements the api.Charger interface
|
||||
func (wb *Delta) Enabled() (bool, error) {
|
||||
b, err := wb.conn.ReadHoldingRegisters(wb.base+deltaRegEvseChargingPowerLimit, 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue