In itâs current form both the âstate.iconUrlâ and the textIconUrl() have valid data until i try to reference them in the attributeState "default", label: '${currentValue} W', icon: '${textIconUrl()}',
I just tried to replace the " " with â â and it allowed me to save and publish but the icon is still blank
I believe the metadata part of the code is executed before anything else is available. I think itâs used to create a description of the device/SmartApp for the client to use.
You may notice that the â${currentValue} Wâ has single quotes around it, this means that it wonât get evaluated at this point but by something later (I suspect the client side does a token replacement). Double quotes in Groove make a GString which are lazily evaluated when they contain a template which is why your code ran initially and gave you the error. Changing to single quotes is now simply setting the value to â${textIconUrl()}â as a raw string which is then given to client which doesnât know what to do about it.
I am not sure what you want to do is even possible unfortunately.
I think it actually needs to be single quotes around it to start with.
Important
Notice anything strange about the label value for state? It appears to be using Groovyâs string interpolation syntax (${}), but with a single quote. In Groovy, String interpolation is only possible for strings defined in double quotes. So, what gives?
When the SmartThings platform executes the tiles() method you have defined, it doesnât yet know anything about the actual devices. Only later, when the device details screen is rendered in the mobile client, does the platform know information about the specific devices.
So, we use single quotes for the label (${name}) because the platform can then manually substitute the actual value later, when it is available.
Long story short - the above is not a typo. Use single quotes for interpolated string values in the tiles definition.
Iâm not convinced that state is given to the client so I doubt itâd know how to evaluate that. Also, I think at this point weâre in the context of the whatever the tile has been assigned to (in this case device.power) so itâs possible that the client would be looking for âdevice.power.state.iconUrlâ
I donât think you can refer to anything outside of the context of the attribute thatâs assigned to the tile (device.power). Youâd have to set the tile to use âdevice.iconUrlâ and then have the icon use â${currentValue}â⌠but the issue arises that the label canât be used to display anything meaningful.