fix(pkg/sensor): read values
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
package temperature
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/go-flucky/flucky/pkg/types/typeswitch"
|
||||
|
||||
"github.com/go-flucky/flucky/pkg/rgbled"
|
||||
|
||||
"github.com/go-flucky/flucky/pkg/cli"
|
||||
@ -40,14 +43,17 @@ var readTemperatureCmd = &cobra.Command{
|
||||
sensors = cnf.GetTemperatureSensorsByName(args)
|
||||
}
|
||||
|
||||
measuredValues, err := sensor.Read(sensors)
|
||||
ctx := context.Background()
|
||||
measuredValues, err := sensor.Read(ctx, sensors)
|
||||
if err != nil {
|
||||
rgbled.Error(rgbLEDs)
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
temperatures := typeswitch.TemperatureValues(measuredValues)
|
||||
|
||||
// print temperatures on stdout
|
||||
cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout)
|
||||
cli.PrintMeasuredValues(temperatures, cnf, os.Stdout)
|
||||
|
||||
if logs {
|
||||
logfile := logfile.New(cnf.Device.Logfile)
|
||||
|
Reference in New Issue
Block a user