Vestel: Fix charger status (#5612)
* fix status * add phase voltages api
This commit is contained in:
parent
da89ddd3fc
commit
bf41bec141
1 changed files with 22 additions and 3 deletions
|
|
@ -42,9 +42,11 @@ const (
|
|||
vestelRegSessionEnergy = 1502
|
||||
vestelRegFailsafeTimeout = 2002
|
||||
vestelRegAlive = 6000
|
||||
//vestelRegChargepointState = 1000
|
||||
)
|
||||
|
||||
var vestelRegCurrents = []uint16{1008, 1010, 1012}
|
||||
var vestelRegCurrents = []uint16{1008, 1010, 1012} // non-continuous uint16 registers!
|
||||
var vestelRegVoltages = []uint16{1014, 1016, 1018} // non-continuous uint16 registers!
|
||||
|
||||
// Vestel is an api.Charger implementation for Vestel/Hymes wallboxes with Ethernet (SW modells).
|
||||
// It uses Modbus TCP to communicate with the wallbox at modbus client id 255.
|
||||
|
|
@ -114,11 +116,11 @@ func (wb *Vestel) Status() (api.ChargeStatus, error) {
|
|||
res := api.StatusA
|
||||
|
||||
b, err := wb.conn.ReadInputRegisters(vestelRegCableStatus, 1)
|
||||
if err == nil && binary.BigEndian.Uint16(b) > 0 {
|
||||
if err == nil && binary.BigEndian.Uint16(b) >= 2 {
|
||||
res = api.StatusB
|
||||
|
||||
b, err = wb.conn.ReadInputRegisters(vestelRegChargeStatus, 1)
|
||||
if err == nil && binary.BigEndian.Uint16(b) > 0 {
|
||||
if err == nil && binary.BigEndian.Uint16(b) == 1 {
|
||||
res = api.StatusC
|
||||
}
|
||||
}
|
||||
|
|
@ -228,6 +230,23 @@ func (wb *Vestel) Currents() (float64, float64, float64, error) {
|
|||
return currents[0], currents[1], currents[2], nil
|
||||
}
|
||||
|
||||
var _ api.PhaseVoltages = (*Vestel)(nil)
|
||||
|
||||
// Voltages implements the api.PhaseVoltages interface
|
||||
func (wb *Vestel) Voltages() (float64, float64, float64, error) {
|
||||
var voltages []float64
|
||||
for _, regVoltage := range vestelRegVoltages {
|
||||
b, err := wb.conn.ReadInputRegisters(regVoltage, 1)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
|
||||
voltages = append(voltages, float64(binary.BigEndian.Uint16(b)))
|
||||
}
|
||||
|
||||
return voltages[0], voltages[1], voltages[2], nil
|
||||
}
|
||||
|
||||
var _ api.Diagnosis = (*Vestel)(nil)
|
||||
|
||||
// Diagnose implements the api.Diagnosis interface
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue