fix(pkg/config): get temperature or humidity sensors
This commit is contained in:
parent
8005248262
commit
4975ce21fa
@ -226,25 +226,27 @@ func (c *Configuration) EnableSensor(name string) error {
|
||||
|
||||
// GetHumiditySensors returns a list of humidity sensors
|
||||
func (c *Configuration) GetHumiditySensors(option Option) []sensor.Sensor {
|
||||
humiditySensors := c.getHumiditySensors()
|
||||
sensors := c.getHumiditySensors()
|
||||
|
||||
cachedSensors := make([]*types.Sensor, 0)
|
||||
|
||||
switch option {
|
||||
case ENABLED:
|
||||
for i, humiditySensor := range humiditySensors {
|
||||
if !humiditySensor.SensorEnabled {
|
||||
humiditySensors = append(humiditySensors[:i], humiditySensors[i+1:]...)
|
||||
for _, sensor := range sensors {
|
||||
if sensor.SensorEnabled {
|
||||
cachedSensors = append(cachedSensors, sensor)
|
||||
}
|
||||
}
|
||||
return c.convertSensors(humiditySensors)
|
||||
return c.convertSensors(cachedSensors)
|
||||
case DISABLED:
|
||||
for i, humiditySensor := range humiditySensors {
|
||||
if humiditySensor.SensorEnabled {
|
||||
humiditySensors = append(humiditySensors[:i], humiditySensors[i+1:]...)
|
||||
for _, sensor := range sensors {
|
||||
if !sensor.SensorEnabled {
|
||||
cachedSensors = append(cachedSensors, sensor)
|
||||
}
|
||||
}
|
||||
return c.convertSensors(humiditySensors)
|
||||
return c.convertSensors(cachedSensors)
|
||||
default:
|
||||
return c.convertSensors(humiditySensors)
|
||||
return c.convertSensors(cachedSensors)
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,25 +323,27 @@ func (c *Configuration) GetRGBLEDsByName(names []string) []rgbled.RGBLED {
|
||||
|
||||
// GetTemperatureSensors returns a list of temperature sensors
|
||||
func (c *Configuration) GetTemperatureSensors(option Option) []sensor.Sensor {
|
||||
temperatureSensors := c.getTemperatureSensors()
|
||||
sensors := c.getTemperatureSensors()
|
||||
|
||||
cachedSensors := make([]*types.Sensor, 0)
|
||||
|
||||
switch option {
|
||||
case ENABLED:
|
||||
for i, temperatureSensor := range temperatureSensors {
|
||||
if !temperatureSensor.SensorEnabled {
|
||||
temperatureSensors = append(temperatureSensors[:i], temperatureSensors[i+1:]...)
|
||||
for _, sensor := range sensors {
|
||||
if sensor.SensorEnabled {
|
||||
cachedSensors = append(cachedSensors, sensor)
|
||||
}
|
||||
}
|
||||
return c.convertSensors(temperatureSensors)
|
||||
return c.convertSensors(cachedSensors)
|
||||
case DISABLED:
|
||||
for i, temperatureSensor := range temperatureSensors {
|
||||
if temperatureSensor.SensorEnabled {
|
||||
temperatureSensors = append(temperatureSensors[:i], temperatureSensors[i+1:]...)
|
||||
for _, sensor := range sensors {
|
||||
if !sensor.SensorEnabled {
|
||||
cachedSensors = append(cachedSensors, sensor)
|
||||
}
|
||||
}
|
||||
return c.convertSensors(temperatureSensors)
|
||||
return c.convertSensors(cachedSensors)
|
||||
default:
|
||||
return c.convertSensors(temperatureSensors)
|
||||
return c.convertSensors(cachedSensors)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user