fix(cmd/sensor): set tick duration for new sensors

This commit is contained in:
2020-01-11 13:18:38 +01:00
parent 40857249c4
commit 002f3e9e25
3 changed files with 28 additions and 18 deletions

View File

@ -81,6 +81,11 @@ func (c *Configuration) AddSensor(sensor *types.Sensor) error {
}
}
// check if sensor has a valid tick time
if _, err := time.ParseDuration(sensor.TickDuration); err != nil {
return fmt.Errorf("Can not parse tick duration: %v", sensor.TickDuration)
}
// check if sensor has a valid device id
if sensor.DeviceID != c.Device.ID {
sensor.DeviceID = c.Device.ID