Vestel: Fix charger status (#5612)

* fix status

* add phase voltages api
This commit is contained in:
premultiply 2022-12-29 22:38:55 +01:00 • committed by GitHub
parent da89ddd3fc
commit bf41bec141
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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