Skip to content

Commit

Permalink
Correctly parse negative (Celsius) temperatures
Browse files Browse the repository at this point in the history
I have had this patch running for weeks and in locations with
temperatures as low as -8 C
  • Loading branch information
jimbrowne authored and cliviu74 committed Dec 29, 2021
1 parent 7ba331b commit c25da0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func readOnewireDevicePayload(deviceID string) (float64, error) {
log.WithFields(log.Fields{"devicePayloadFile": devicePayloadFile}).Error("Error reading Device")
return 0, err
}
re := regexp.MustCompile(`(?s).*YES.*t=([0-9]+)`)
re := regexp.MustCompile(`(?s).*YES.*t=(-?[0-9]+)`)
value, _ := strconv.ParseFloat(re.FindStringSubmatch(string(buffer))[1], 64)
return value / 1000, nil
}
Expand Down

0 comments on commit c25da0d

Please sign in to comment.