Need Help With Updating standardTile Label


#1

I am setting some tiles as standardTiles and labelling them based on preferences input. I am using standardTile versus valueTile due to issues in iOS rendering and I want the alignment that comes with a standardTile. Here’s an example of the code for one tile:

standardTile("Push 1", "device.lblPush${1}", width: 2, height: 2, decoration: "flat") { 
            	state("default", label: '${currentValue}', action: "push${1}", defaultState: true, icon: "https://raw.githubusercontent.com/Nezmo68/SmartThingsPublic/master/Button-1.png", canChangeBackground: true)
            }

Here’s how my tile looks when first rendered in the handler:

Image-1-1

When the tile is tapped the correct event is triggered but the label changes as follows:

IMG_9253

A refresh resets the label. Is there a way I can code this to stop that label changing to PUSH1?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

Ummm… Don’t put "${currentValue}“ in the code snip (as the label parameter…).


#3

That’s the only way I know to get the value set in prefs to go in there. I do not want to hard code the labels in the handler code.


(Dave Gutheinz) #4

You can hard code the value to be what every you want: i.e., label: 'My Custom Label"


#5

I don’t think I am explaining myself adequately.

I do not want to hard code any label in the code. The labels are defined in the preferences in the handler - ie, they are set-up by the user so they can be different for each device that uses the handler.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #6

I think I understand, Nez.

The problem is that you have found a “workaround” to a hard limitation in DTHs, and that workaround is pretty … limited.

As far as I know, the only _variable _values permitted for label: are $currentValue and $name.

It’s pretty limited because Tiles are a part of the the DTH definition … they are not a part of the code.


#7

That was my suspicion, thanks.

Right, this is correct.


What I was hoping is that there’s something else I can do like force a ‘refresh’ (as an example) as a manual refresh does what I want.

I came across the following thread but I can’t translate it in my head for my needs … The following is something very different but along the lines of what I’m trying to do. In this case they are trying to update a tile based on an action on another tile. In my case I am wanting to update all tiles when any are tapped. But I realize I may just be trying to do something that’s not possible.


(Allan) #8

I tried to do this for weeks and gave up. It can’t be done how you want it to. The only option is to give the users a list of possible options as your preference and then based on that list (which you know the possible values) use a big If then statement to call the right label.

See this for the thread I posted: Change labels of child device programatically?

And this for a example of code I used. It’s the “Child Contact Sensor” used with the ST_Anything project but modified to be more useful for different types of contacts. I did the same with the Konnected Contact Sensor also: https://github.com/vseven/SmartThings_VSeven/blob/master/devicetypes/vseven/child-contact-sensor.src/child-contact-sensor.groovy


#9

Thanks for the additional input Allan.


I could just use valueTile of course as it solves my labelling problem but I think the rendering is a bit crappy. I was really hoping to find a workaround on this as otherwise I have a really cool looking Minimote simulator (again, want to give credit to @kyse as I used his framework).

Here’s where I was going with it …

I think what I will do is just create 7 versions (I currently have 7 Minimotes) and hard code the labels and be done with it.