feat: rename sensor name

This commit is contained in:
2019-02-28 20:05:23 +01:00
parent 14ce354b32
commit 450dfc9052
2 changed files with 51 additions and 0 deletions

View File

@ -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