I'm working on a driver and it appears that installed is only called on initial install (expected really). This also appears to be the only time the settings
Map is updated with inputs and their default values.
If I add a new input in the preferences metadata no default value is populated in the settings. Manually running configure/refresh don't seem to do anything either does changing the device to another device type and then back.
I guess I'm curious what people's development flows are when adding a new input doesn't guarantee that there will be a default value populated. In SmartThings I could traverse down the preferences
object and introspect the defaultValue fields but the sections
field appears to be empty in hubitat:
private getDefaultsMap() {
if (DEFAULTS_MAP.isEmpty()) {
for (section in preferences?.sections) {
for (input in section?.input) {
if (input.name && input.defaultValue) {
DEFAULTS_MAP[input.name] = input.defaultValue
}
}
}
}
return DEFAULTS_MAP;
}
Is there a way to re-run the install event without actually uninstalling/reinstalling the device?
This is probably a misunderstanding on my part...but I always assumed that the defaultValue simply prepopulated a value for the input. The value didn't actually get saved in Settings until...well until you clicked on the Save button. If I'm wrong, it definitely won't be the first time. This is one for @chuck.schwer.
If you log.info "SETTINGS: ${settings}"
you get something that looks like:
SETTINGS: [logLevel:info, dimUpInput:IN1, dimDownInput:IN2, motionInput:IN3, dimUpThreshold:50, dimDownThreshold:50, motionThreshold:50, configParam09:1, configParam10:10, configParam12:255, configParam13:2, configParam16:1, configParam44:30, configParam45:10]
That is for a driver where those are all the inputs and their default values immediately after installing a virtual device with the driver.
Problem is if I then add another input it never shows up in the Map. I'll throw together a demo driver in a little bit.
If you open (or refresh) the device page, the new input with default values should be there. You would need to hit the Save Pref button and it would then be added to the settings map. Again, I can't say if that is what it should do...but that is how it has always worked for me in HE..I think.
I don't remember the behavior in ST.
Yes, that works, if I add the new input and click save it populates. On initial install you never have to do that initial save though, the inputs just magically populate into the settings map. Just wondering if it is intended that adding a new input doesn't update the settings map.
Found: clearSetting(String) Device Object - Hubitat Documentation
Just need to figure out how to make it work on a driver vs an app