Handle empty file on temperature reading

This commit is contained in:
Søren Rasmussen 2022-08-03 15:30:52 +02:00
parent 15f6d277a9
commit c38b8e1ae6

View file

@ -248,6 +248,10 @@ func read(sensor string) (int64, error) {
raw := string(data)
if raw == "" {
return NaN, fmt.Errorf("%v: %w: empty file", sensor, ErrReadSensor)
}
if !strings.Contains(raw, " YES") {
return NaN, fmt.Errorf("%v: %w: checksum failed [%v]", sensor, ErrReadSensor, raw)
}