fix(pkg/config): select temperature and humidity sensors by name, uuid or wire-id

This commit is contained in:
2019-06-15 13:02:52 +02:00
parent 314f5a41e5
commit 662e1dcfa9
2 changed files with 101 additions and 14 deletions

View File

@ -27,8 +27,13 @@ var readTemperatureCmd = &cobra.Command{
log.Fatalln(err)
}
// fetch all temperature sensors
temperatureSensors := cnf.GetTemperatureSensors(config.ENABLED)
// fetch all temperature sensors or sensors by args
temperatureSensors := make([]sensor.TemperatureSensor, 0)
if len(args) == 0 {
temperatureSensors = cnf.GetTemperatureSensors(config.ENABLED)
} else {
temperatureSensors = cnf.GetTemperatureSensorsByName(args)
}
// read temperature from sensors
temperatures, err := sensor.ReadTemperatures(temperatureSensors)