Skip to content

Commit

Permalink
When saving a device, set new UUID if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamaTheHutt committed Sep 2, 2019
1 parent ffbe2cb commit c626f28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions telldus/src/telldus/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ def flattenContainingDevices(self):
toCheck.extend(d.containingDevices())
return devices

def getOrCreateUUID(self):
if self.uuid():
return str(self.uuid())
else:
self._uuid = uuid.uuid4()
return str(self.uuid())

# pylint: disable=W0212
def loadCached(self, olddevice):
self._id = olddevice._id
Expand Down
2 changes: 1 addition & 1 deletion telldus/src/telldus/DeviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def save(self):
stateValues = device.stateValues()
dev = {
"id": device.id(),
"uuid": device.uuidAsString(),
"uuid": device.getOrCreateUUID(),
"loadCount": device.loadCount(),
"localId": device.localId(),
"type": device.typeString(),
Expand Down

0 comments on commit c626f28

Please sign in to comment.