I've tried to overcome this by updating the device in deviceStartComm, only to discover that the "states" attribute for a device is read-only - e.g. if I try something like:
- Code: Select all
if ("lastMotionEventId" not in indigoDevice.states):
replacementStates = indigo.Dict()
replacementStates = indigoDevice.states # Make a copy to edit
replacementStates["lastMotionEventId"] = "FOOBAR"
indigoDevice.states = replacementStates
indigoDevice.replaceOnServer()
self.debugLog("Added new custom state lastMotionEventId to existing device %s" % indigoDevice.name)
The following error is produced:
- Code: Select all
Ring Error exception in deviceStartComm(Front Door): the attribute "states" is read-only on this instance
What is the correct way to migrate existing devices to support the newly added state? Do I need to programmatically create a whole new device object to replace the existing one?