Skip to content

Commit

Permalink
Cfos: remove currents due to invalid values (#3074)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Apr 4, 2022
1 parent 07676f7 commit 6151628
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions meter/cfos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
// }

0 comments on commit 6151628

Please sign in to comment.