Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions sensors/sensors_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package sensors

import (
"context"
"math"

"github.com/yusufpapurcu/wmi"

Expand All @@ -30,18 +29,16 @@ func TemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
for _, v := range dst {
ts := TemperatureStat{
SensorKey: v.InstanceName,
Temperature: kelvinToCelsius(v.CurrentTemperature, 2),
Temperature: kelvinToCelsius(v.CurrentTemperature),
}
ret = append(ret, ts)
}

return ret, nil
}

func kelvinToCelsius(temp uint32, n int) float64 {
func kelvinToCelsius(temp uint32) float64 {
// wmi return temperature Kelvin * 10, so need to divide the result by 10,
// and then minus 273.15 to get °Celsius.
t := float64(temp/10) - 273.15
n10 := math.Pow10(n)
return math.Trunc((t+0.5/n10)*n10) / n10
return (float64(temp*10) - 27315) / 100
}