feat: rename sensor name
This commit is contained in:
@ -351,6 +351,18 @@ func (fc *FluckyConfig) RemoveRemote(nameOrUUID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RenameSensor renames a sensor identified by the name or the UUID
|
||||
func (fc *FluckyConfig) RenameSensor(oldName, newName string) error {
|
||||
for _, sensor := range fc.Sensors {
|
||||
if sensor.SensorName == oldName ||
|
||||
sensor.SensorID == oldName {
|
||||
sensor.SensorName = newName
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("Could not find sensor %v and replace the name", oldName)
|
||||
}
|
||||
|
||||
// ToJSON returns the struct as JSON string
|
||||
func (fc *FluckyConfig) ToJSON() (string, error) {
|
||||
var b bytes.Buffer
|
||||
|
Reference in New Issue
Block a user