[sensors] allow sensor readings when there are warnings

This commit is contained in:
anxdpanic authored and Svilen Markov committed 2025-04-15 04:07:50 +01:00
1 parent 8e71afe158
commit 2c3e14d84c
2 files changed
+5 -4

No files matched your search

+4 -3
View File
@@ -96,7 +96,7 @@ func parseCliOptions() (*cliOptions, error) {
func cliSensorsPrint() int {
tempSensors, err := sensors.SensorsTemperatures()
if err != nil {
fmt.Printf("Failed to retrieve list of sensors: %v\n", err)
fmt.Printf("Errors encountered while retrieving list of sensors:\n %v\n", err)
if warns, ok := err.(*sensors.Warnings); ok {
for _, w := range warns.List {
fmt.Printf(" - %v\n", w)
@@ -106,13 +106,14 @@ func cliSensorsPrint() int {
return 1
}
if len(tempSensors) == 0 {
if tempSensors == nil || len(tempSensors) == 0 {
fmt.Println("No sensors found")
return 0
}
fmt.Println("Sensors found:")
for _, sensor := range tempSensors {
fmt.Printf("%s: %.1f°C\n", sensor.SensorKey, sensor.Temperature)
fmt.Printf(" %s: %.1f°C\n", sensor.SensorKey, sensor.Temperature)
}
return 0