I searched and searched for this topic, but didn’t find an answer, so I’m going to write here instead.
I am in the process of making some updates to the Ecobee (Connect) SmartApp to bring it more up to date and to start adding features into the main devicetype and SmartApp combos.
One of the changes that I was making was splitting up the dynamic settings pages into a more logical flow: authentication --> Select Thermostats --> Select Remote Sensors.
For the Remote Sensors, I only want to show the sensors related to the selected thermostats. This all works great the first time the app is invoked. However, if down the line I want to remove a thermostat I also want to remove the corresponding sensors.
Here is the problem that I’m running into. The input for the sensors selection is enum and the options are generated dynamically based on which thermostats are select. But any sensors that were previously selected the first time through remain in the enum setting even if they are not shown on the UI for the enduser.
Here are the steps:
Install the Ecobee (Connect) app (copy it over or link to the IDE. You also need to create the two device types as well for Ecobee Thermostat and Ecobee Sensors)
Do the OAuth login steps
Select two thermostats from the list
Select some remote sensors (pick at least one from each thermostat)
The app should now be fully installed, it should have created two thermostats and all of your sensors
Now, open the smartapp again to make changes
Click next on the OAuth screen (you should still be authenticated)
On the Thermostats screen, deselect one of the two thermostats (Click Next) (We’ll call this Thermostat2 for this example)
On the Sensors screen you should only see sensors associated with the selected Thermostat from the previous step.
At this point, the SmartApp is able to delete the explicitly deselected Thermostat2, however, the sensors that were associated with Thermostat2 were not explicitly deselected as they were never presented to the user, so they are still in the settings variable (settings.ecobeesensors).
How can I remove these sensors from the setting variable? To me, this seems like a bug. If the options were not present on the screen to select, they should not end up in the resulting settings variable.
If you want to look at the full code, it is available in the StrykerSKS-Ecobee3 branch on the SmartThingsPublicCommunity:
In particular, checkout sensorsPage().
Any help would be appreciated.