Orphaned entries persist and accumulate in driver.datastore

Hello,

I’m developing a LAN driver for a gateway with child devices. When I delete and then re-discover devices, their old entries remain in driver.datastore.__devices_store.

Although the SmartThings platform removes the device and calls my driver’s removed lifecycle handler, the corresponding entry in __devices_store isn’t automatically cleaned up. This leads to an accumulation of orphaned data; for instance, deleting a gateway + 10 children leaves 11 orphaned entries, and repeating this delete/re-add process adds another 11 orphaned entries each time.

I considered manually setting driver.datastore.__devices_store[device.id] = nil within the removed handler, but I’m hesitant to access __devices_store directly due to the naming convention suggesting it might be private/internal. Rebooting the hub doesn’t clear these entries either.

Is this persistence and accumulation in __devices_store expected behavior? Or could this indicate a platform bug?

Thanks.

Hi, @AlexanderT

I’m checking this with the engineering team and wanted to clarify with you if this is the behavior you observed:

  1. When you have several devices using the driver and you delete just one, the driver keeps running for the others. The entry is deleted from __devices_store
  2. When you have several devices using the driver and delete all of them. Then, this is when you see the entries are still in __devices_store.

Please let us know so this can confirm the diagnostic made by the team.

Hi @nayelyz

  1. When I delete just one (EDGE_CHILD) device, the driver keeps running for the other devices, yes. The corresponding entry of the delete device remains in the driver.datastore.__devices_store table.
  2. Likewise, if I delete the LAN device, the parent gateway, all children devices get deleted as well, as expected. As described in my first post, all entries in the driver.datastore.__devices_store table would remain.

Hope that helps.

Cheers

ok, so, if the integration discovers 5 devices aside from the parent and you delete 1 child device, the entries of the 6 devices remain in the table, right?

Correct. And to make the issue more apparant - if I delete the gateway, SmartThings would delete the gateway and all its children, which is to be expected. If I then rediscover the gateway in a next step, all its children will be readded as well. But I will have twice as many entries in the table, half of which are orphaned.

1 Like

Ok, thank you for the information. I updated the report generated for this issue.
Once I get more feedback, I’ll let you know.

1 Like