// SPDX-License-Identifier: BSD-3-Clause //go:build linux package sensors import ( "context" "fmt" "os" "path/filepath" "strings" ) // ExTemperature represents Linux dependent temperature sensor data type ExTemperature struct { SensorKey string `json:"key"` Min float64 `json:"min"` // Temperature min value. Lowest float64 `json:"lowest"` // Historical minimum temperature Highest float64 `json:"highest"` // Historical maximum temperature } type ExLinux struct{} func NewExLinux() *ExLinux { return &ExLinux{} } func (ex *ExLinux) TemperatureWithContext(ctx context.Context) ([]ExTemperature, error) { var warns Warnings files, err := getTemperatureFiles(ctx) if err != nil { return nil, fmt.Errorf("failed to get temperature files, %w", err) } temperatures := make([]ExTemperature, 0, len(files)) for _, file := range files { var raw []byte // Get the base directory location directory := filepath.Dir(file) // Get the base filename prefix like temp1 basename := strings.Split(filepath.Base(file), "_")[0] // Get the base path like