Skip to content

Commit

Permalink
Fix wallbe register decoding for officially unsupported SDM meters
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Sep 15, 2020
1 parent f0a14ab commit 58d946b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion charger/wallbe.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ func (wb *Wallbe) ChargingTime() (time.Duration, error) {
func (wb *Wallbe) decodeReading(b []byte) float64 {
v := binary.BigEndian.Uint32(b)

// assuming high register first
if wb.encoding == encodingSDM {
bits := (v&0xffff)<<16 | (v>>16)&0xffff
bits := uint32(b[3])<<0 | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24
f := math.Float32frombits(bits)
return float64(f)
}
Expand Down

0 comments on commit 58d946b

Please sign in to comment.