Ignore temperature magic value -128
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Søren Rasmussen 2022-07-26 12:12:19 +02:00
parent aaf865a72a
commit 8766932739

View file

@ -223,12 +223,12 @@ func read(sensor string) (int64, error) {
raw := string(data) raw := string(data)
if !strings.Contains(raw, " YES") { if !strings.Contains(raw, " YES") {
return 0.0, fmt.Errorf("%w: checksum failed [%v]", ErrReadSensor, raw) return 0.0, fmt.Errorf("%v: %w: checksum failed [%v]", sensor, ErrReadSensor, raw)
} }
i := strings.LastIndex(raw, "t=") i := strings.LastIndex(raw, "t=")
if i == -1 { if i == -1 {
return 0.0, fmt.Errorf("%w: t= not found in [%v]", ErrReadSensor, raw) return 0.0, fmt.Errorf("%v: %w: t= not found in [%v]", sensor, ErrReadSensor, raw)
} }
c, err := strconv.ParseInt(raw[i+2:len(raw)-1], 10, 64) c, err := strconv.ParseInt(raw[i+2:len(raw)-1], 10, 64)
@ -236,5 +236,10 @@ func read(sensor string) (int64, error) {
return 0.0, err return 0.0, err
} }
// Ignore magic value -128
if c == -128000 {
return 0.0, fmt.Errorf("%v: magic value -128 detected", sensor)
}
return c, nil return c, nil
} }