fix(pkg/daemon): use all enables sensors instead of only temperature sensors

This commit is contained in:
Markus Pesch 2019-06-27 20:33:40 +02:00
parent 6d3781d950
commit 45763d7c9d
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 25 additions and 1 deletions

View File

@ -321,6 +321,30 @@ func (c *Configuration) GetRGBLEDsByName(names []string) []rgbled.RGBLED {
return c.convertRGBLEDs(rgbLEDs) return c.convertRGBLEDs(rgbLEDs)
} }
// GetSensors returns a list of humidity sensors
func (c *Configuration) GetSensors(option Option) []sensor.Sensor {
cachedSensors := make([]*types.Sensor, 0)
switch option {
case ENABLED:
for _, sensor := range c.Sensors {
if sensor.SensorEnabled {
cachedSensors = append(cachedSensors, sensor)
}
}
return c.convertSensors(cachedSensors)
case DISABLED:
for _, sensor := range c.Sensors {
if !sensor.SensorEnabled {
cachedSensors = append(cachedSensors, sensor)
}
}
return c.convertSensors(cachedSensors)
default:
return c.convertSensors(cachedSensors)
}
}
// GetTemperatureSensors returns a list of temperature sensors // GetTemperatureSensors returns a list of temperature sensors
func (c *Configuration) GetTemperatureSensors(option Option) []sensor.Sensor { func (c *Configuration) GetTemperatureSensors(option Option) []sensor.Sensor {
sensors := c.getTemperatureSensors() sensors := c.getTemperatureSensors()

View File

@ -37,7 +37,7 @@ func Start(cnf *config.Configuration, cleanCacheInterval time.Duration, compress
measuredValuesCache := make([]types.MeasuredValue, 0) measuredValuesCache := make([]types.MeasuredValue, 0)
go sensor.ReadContinuously(childContext, cnf.GetTemperatureSensors(config.ENABLED), measuredValuesChannel, errorChannel) go sensor.ReadContinuously(childContext, cnf.GetSensors(config.ENABLED), measuredValuesChannel, errorChannel)
rgbLEDs := cnf.GetRGBLEDs(config.ENABLED) rgbLEDs := cnf.GetRGBLEDs(config.ENABLED)