fix(pkg/cli): GetSensorIDsByMeasuredValues

This commit is contained in:
2020-01-11 12:10:26 +01:00
parent f1a4ade402
commit b595cf1ac8
3 changed files with 23 additions and 32 deletions

View File

@ -82,8 +82,8 @@ func (c *Configuration) AddSensor(sensor *types.Sensor) error {
}
// check if sensor has a valid device id
if sensor.ID != c.Device.ID {
sensor.ID = c.Device.ID
if sensor.DeviceID != c.Device.ID {
sensor.DeviceID = c.Device.ID
}
// overwrite creation date
@ -362,6 +362,17 @@ func (c *Configuration) GetRGBLEDsByName(names []string) []rgbled.RGBLED {
return c.convertRGBLEDs(rgbLEDs)
}
// GetSensorByID returns a sensor matched by his id. If no sensor has this id,
// the function returns nil
func (c *Configuration) GetSensorByID(id string) *types.Sensor {
for _, sensor := range c.Sensors {
if sensor.ID == id {
return sensor
}
}
return nil
}
// GetSensors returns a list of humidity sensors
func (c *Configuration) GetSensors(option Option) []sensor.Sensor {
cachedSensors := make([]*types.Sensor, 0)