Cfos: remove currents due to invalid values (#3074)

This commit is contained in:
andig 2022-04-04 09:51:32 +02:00 • committed by GitHub
parent 07676f7820
commit 6151628dd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,7 +13,7 @@ const (
cfosRegPower = 8062 // power reading
)
var cfosRegCurrents = []uint16{8064, 8066, 8068} // current readings
// var cfosRegCurrents = []uint16{8064, 8066, 8068} // current readings
// CfosPowerBrain is a meter implementation for cFos PowerBrain wallboxes.
// It uses Modbus TCP to communicate at modbus client id 1 and power meters at id 2 and 3.
@ -78,19 +78,19 @@ func (wb *CfosPowerBrain) TotalEnergy() (float64, error) {
return float64(binary.BigEndian.Uint64(b)) / 1e3, err
}
var _ api.MeterCurrent = (*CfosPowerBrain)(nil)
// var _ api.MeterCurrent = (*CfosPowerBrain)(nil)
// Currents implements the api.MeterCurrent interface
func (wb *CfosPowerBrain) Currents() (float64, float64, float64, error) {
var currents []float64
for _, regCurrent := range cfosRegCurrents {
b, err := wb.conn.ReadHoldingRegisters(regCurrent, 2)
if err != nil {
return 0, 0, 0, err
}
// // Currents implements the api.MeterCurrent interface
// func (wb *CfosPowerBrain) Currents() (float64, float64, float64, error) {
// var currents []float64
// for _, regCurrent := range cfosRegCurrents {
// b, err := wb.conn.ReadHoldingRegisters(regCurrent, 2)
// if err != nil {
// return 0, 0, 0, err
// }
currents = append(currents, float64(binary.BigEndian.Uint32(b))/10)
}
// currents = append(currents, float64(binary.BigEndian.Uint32(b))/10)
// }
return currents[0], currents[1], currents[2], nil
}
// return currents[0], currents[1], currents[2], nil
// }