@gausnes I ran into this issue today while developing a SmartApp Service Manager that creates and delete child devices.
The basic flow of the installed method is
- Find new devices and install them using
addChildDevice
- Find dead/orphaned devices and remove them using
deleteChildDevice
- Get a list of child devices using
getChildDevices
- Subscribe to the device event using
subscribe(getChildDevices(), "event", handler)
There appears to be some caching bug going on with deleteChildDevice
. After calling deleteChildDevice
, when I call getChildDevices
, the recently deleted device STILL shows up in the list of child devices.
Then when the SmartApp calls subscribe with getChildDevices() it thows an error:
bb59d7ee-ac6f-40d2-a68f-c8efb02c35ff 10:43:42 PM: error org.springframework.security.access.AccessDeniedException: Access is denied @ line 676
It basically craps out on the subscribe command because getChildDevices() is returning a deleted device in it’s list.
I confirmed this with 2 tests:
- If I don’t do subscribe it goes through fine and getChildDevice returns the correct list of devices
- If I don’t do a call to deleteChildDevice it also goes through fine and subscribe succeeds
Any idea why deleteChildDevice followed by a getChildDevices and a subscribe command is causing the platform to cache and return the deleted child device?