ValueTile anatomy?

I’ve been looking for some documentation on the parameters to ValueTile without much luck. In What little documentation I find I see examples like:

valueTile("heatingSetpoint", "device.heatingSetpoint", inactiveLabel: false, decoration: "flat") {
    state "heat", label:'${currentValue}° heat', backgroundColor:"#ffffff"

What is that second parameter for (“device.heatingSetpoint” in this example)?

Can the ${currentValue} in the label be replaced with something else like ${state.zoneNumber}?

I’m trying to display some configuration data that doesn’t come from an event but I’m having zero luck.

I have been looking for some decent documentation also with no luck. please post back if you find a link.

The second argument is the device attribute name. Standard attributes are defined here:

You can define custom attributes in the metadata ‘definition’ section:

attribute "MyAttribute", "string"

and use it just like standard attributes, e.g.:

def foo = device.currentValue("MyAttribute")

Thanks, @geko. That was very helpful! I think what I have should be working, but my ValueTile shows “–”.

In the metadata section I have:

attribute "zoneNumber", "number"

Then below in Tiles I have:

        valueTile("zoneNumber", "device.zoneNumber", decoration: "flat") {
            state "default", label:'${currentValue}'

The zoneNumber attribute is being set via sendEvent and if I look at the device in the ide it shows there zoneNumber having a value of 1 but in the tile on the mobile app it just shows as “–”. I must be missing something simple and obvious.

Devices are funky. In my experience, whenever I change device UI, it does not update until I log out of the mobile app, then kill/restart it.

Thanks again, @geko. I followed those steps and lo’ and behold it worked. Sigh. It’s hard to debug when you can’t trust what the tools are showing you. Hours wasted and frustration mounted… and my code was right all along. Sigh, again.

1 Like

Hear, hear… Developing for ST is like walking in the mind field. Got to wear a helmet and steel boots at all times :slight_smile:

1 Like

I’ve got another valueTile question. I can make standardTile work the way I expect but valueTile seems to have different semantics than I am expecting. I have this:

		valueTile("status", "device.status") {
		    state "ok", label:'OK',backgroundColor:"#79b821"
		    state "lowBattery", label:'Low\nBattery',backgroundColor:"#ffa81e"
		    state "default", label:'Unknown',backgroundColor:"#333333"

The “status” attribute is “ok” but “Unknown” is what shows up in the tile display. Anyone have any idea what I’m doing wrong?

From what I have gathered if you want to use the various states, use the standard tile. If you want to display a value use the value tile. I would use the standard tile for the example you posted.

ST seems pretty restrictive in the way data gets presented. A standardTile would be fine except that I don’t have icons for these and if I use a standardTile the text gets stuffed down in the bottom and there is a large blank area at the top.

If I use a valueTile normally I get unpretty text. There doesn’t seem to be any good way to transform text before display.

I agree. Custom tiles give me nothing but endless grief. :-\

I’ve been trying to think of a way to visualize a small amount of variables that are happening within my SmartApp. Any new creative ways anyone has used tiles to show values? (Virtual device)