My smartapp has preferences about a list of devices that get installed or removed based on what the user selects in the preference page. My problem is that when the user deselects one of the child devices, and removal fails (for instance because it is still in use by another smartapp), the device is removed from my preferences list, but it still actually exists, causing a mismatch between preference and actual list of devices. I have tried multiple approaches to counter this but nothing works:
When my code hits the “settings” method first try to see if there is a mismatch between actual child devices and the preferences list, then update the preference list: doesn’t work because I can’t seem to manipulatie settings before they appear on screen
Try to figure out if the device is in use and then disable the unchecking of the device in my prefs: I cant seem to figure out any method of checking if a device is in use by something else and also I cannot block the unchecking of a preference
Preventing prefs from being saved when an error occurs on exiting the settings page: also not possible; the prefs save occurs first and then deletion fails.
Any ideas? I’m working with a dynamic preferences page.