RBoy
(www.rboyapps.com - Making SmartThings Easy!)
1
I’m trying to use a dynamic variable for the name of a input device in a SmartApp. It doesn’t seem to work. It won’t remember it when you load it the next time, the variable value is stored in settings but the input parameter seems to ignore the stored value.
and i’ve tried every possible combination, keeping only name, only type, removing space etc. Nothing! Only I remove them both it works.
@Jim and @tslagle13 tagging you guys for your inputs please. Jim has the documentation changed? BTW I don’t see defaultValue as an option in the documentation anymore.
If it’s not documentation then Tim is this a IDE or a platform bug? (the result is replicable on iOS and Android so I’m guessing it’s a platform issue)
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
3
def myVal = "cpVal_" + n
OR
def myVal = "cpVal_${n}"
result = input(
name : myVal
,title : "string value"
,type : "text"
,required : false
)
where n is some ordinal that you maintain
The return result bit is optional, but useful for including the input field into a method.
Input (…, will stand on it’s own within a standard or dynamic page.
1 Like
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
6
It does not work with
type: “capability.switch”
I know with non capability types everything is okay but when the type is capability and you introduce a variable in the name, specifying the tags for name and type causes it to break.
Still waiting for someone from ST to comment on it. @Ben should I be reporting this to support or bring it to someone else’s attention?
you specifically tried this without using the inline gString representation?
gStrings are evaluated late, and I have for a fact seen the code sample in your initial post fail…
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
8
Yes and it doesn’t work.
BTW the inline representation works just fine as long as the type isn’t capability, i.e with type text my original code works fine.
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
9
you’re missing the whole point, without the tags it works, with the tags (name/type) it doesn’t - and this is specific to type capability, so what’s going on?
@RBoy are you still seeing this? I tested using the name/type named parameters and is working for me.
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
13
No @Jim it still doesn’t work. If I put a variable in the name and type is capability.switch, the moment I specify the tags name and type it stops working.
HI @RBoy, hope you are having a good holiday season as well!
Yes defaultValue is supported. Regarding the input variables, can you perhaps create a gist of a simple SmartApp that illustrates the issue? And if you are reproducing on Android and/or iOS.
I created a simple example here, but it is working for me on ios and Android, so a simple example that reproduces the issue will allow us to create an internal ticket for the issue.
Thanks!
1 Like
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
18
@Jim going back to my earlier post, the dynamic variables don’t work when using with a type “capability.switch”. In your example you’re using type “text”.
Same for defaultValue with using with type “capability.switch” it doesn’t work.
Ok… I think there may be a couple issues here. Help me unpack them:
Setting default values of a device input isn’t working as you’d expect.
When using name and type explicitly to input() the preference values are not saving. I see them working within the preferences page, but then when hitting Install, if I open it back up the values are gone.
Regarding 1), you can use the device id to set the default value (see the gist for an example).
Regarding 2), no clue. We can pass it on to engineering. Are you seeing this in general or just in specific cases? i.e, are you always seeing that any device input that uses the name/type form doesn’t save the selected values, or just in this case?
Thanks!
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
20
Perfect Jim, you’re there. Your sample code is spot on.
I was suggesting if you could document the correct usage of defaultValue and what types of inputs it applies to and if there is any difference in the way it should be used.