feat: rename sensor name

This commit is contained in:
volker.raschek committed 2019-02-28 20:05:23 +01:00
1 parent 14ce354b32
commit 450dfc9052
2 files changed
+51

No files matched your search

+12
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