Feature Request: Allow Android to process defaultValue for inputs (like iPhone)

I maintain a number of SmartApps and device handlers, which I develop and test using my iPhone, and publish to the community. I use the defaultValue option on all my preferences inputs, because it’s very useful and saves time when commissioning new devices.

However, I continually get requests from other community members to fix the bug where the Android version of the SmartThings app does not process the defaultValue option properly (it looks like it does, as it puts a value in the box, it just doesn’t save it).

It’s absolutely crazy that SmartThings STILL haven’t fixed the issue of processing defaultValues on Android. Simply adding an addendum to the documentation saying not to use defaultValue isn’t that helpful when the feature works and is very useful on iPhones. :imp:

Please, please, please fix this! :sob:


Can you elaborate on this a little? Do you mean before someone goes to preferences and hits “Done” or after? Because I haven’t seen this after hitting done.

What I’ve noticed is that on any enum variable, there is no default displayed, just the description, when you first go to preferences. But once you hit done the default value is populated and I see it in the handler debugging as well that it’s being used. At least I think I have. :slight_smile:

This is what I hear from Android users:

For any most input types (e.g. number, string), if the current value of an input setting is null, and a defaultValue is set in the code, then when the Settings page is opened, the GUI will show the default value in the input box. However, when the user hits Done and the settings are supposedly saved, the value of the inputs is still null.

This creates confusion for Android users, because it looks like the values are set, but they are not saved.
The solution at the moment appears to be that Android users must go though all settings boxes, delete the existing value, and manually re-enter the desired value.

In the iPhone app, it behaves in a similar way: if the current value of an input setting is null, and a defaultValue is set in the code, then when the Settings page is opened, the GUI will show the default value in the input box, but the difference is, when the user hits Done, the value is actually saved.

1 Like

I just tested it on android and it worked perfect for me. All I had to do was hit “done” and the values were set.

I created a new preference on an existing device (so the input would automatically be null) I set a log.debug in the updated method to show me the values. They were set to the defaults.

I did have some weird issues with required values - they will not grab the defaults - but otherwise it was fine.

Perhaps that’s the real issue. If an input is required, then the Android app fills in the defaultValue, but when you come to save the settings (by hitting Done) it doesn’t register that there is any value there and won’t let you save. The user is then stuck, because they appear to have all inputs completed, but they still can’t save them.

I should probably defer to some of the users who’ve asked me to remove defaultValues from my code:

@cscheiene, @steve.bratt , @Alwas please can you explain exactly what the issues are?

From what I’ve seen, default values (except enums) populate, but if the field is required, you can’t save unless you enter each field. To get around this, I still set a default value, but I don’t use any required fields and wrap the settings so that if a value isn’t entered it uses the default value.

Setting the default value of an enum has no visual effect which ends up confusing the user because they have no idea what the default is. I usually add “(default)” to the default item in the enum to make it less confusing.

In both of these situations, if the fields are not required, the user can open the settings, tap done, and the next time they open the settings everything will be populated correctly.

My solution is time consuming and adds unnecessary complexity. Everything works the way its supposed to in iOS and it used to work fine in Android so I don’t know why it’s taking so long for them to fix this.

I think the android bug that should be a higher priority is the inability to select multiple items from an enum. When an enum is marked multiple, the user can select multiple items and it displays the items they selected, but only the first item they selected from that list gets saved in the field. The next time they open the settings, the other items are no longer selected.

1 Like

You described it very well.

When the input is required and filled in by default value, when you then hit “Done” it comes up with something like: please fill in all required fields" But all the fields are blue and already filled inn. So you are stuck and cannot save the config. All you can do is hit the back button.


Ok, so I think we’ve manage to describe to problem fairly well now. :slight_smile:

So, SmartThings ( @duncan, @slagle, @Staff_Members ), please can we get these issues fixed ASAP. It’s been driving me and many other crazy for many months, and I don’t even own an Android phone!!!


I raised a developer case about this weeks ago and heard nothing back. Although I must admit I had not made the ‘required value’ connection. One of the issues is as stated above. Smartthings will show a message saying please enter all required values, yet all the values show up in blue as entered. I once tried removing and replacing all the values one by one, but I still got the error message at the end. I could have missed a value but there were 30 or more of them which made it a right pain. And while I was capable of doing it, I was certain a basic user would struggle.