Need a hand getting started with device tiles

Hi all,

I’ve read the doc, looked over the examples and done some Google-fu but I’m really none the wiser!

I just need a slight helping hand to get started with adding a valueTile to a power outlet, this is what I have:

tiles { valueTile("power", "device.power", decoration: "flat") { state "power", label:'hello' } main(["power"]) details(["power"]) }

I get no errors, but it also does nothing at all! If someone was a working snippet they could share I would really appropriate it.

Thank you very much, sorry for what is probably such a noob question!

You need to add an action argument to your state method it.

valueTile("power", "device.power", decoration: "flat") {
  state("power", label: '${currentValue}', action: "refreshPowerState", defaultState: true)

You’ll notice that device.power capabilities has no attributes/commands associated with it though. So if in my example, I’ve targeted a custom command called refreshPowerState. In your device handler’s metadata definition, you’d add:

metadata {
  definition(....) {
    command "refreshPowerState"

Then define a method to do stuff for your new command of course…

def refreshPowerState() {

You could customize it and define an attribute in your metadata definition, and have your tile target device.attributename, then in your tile’s state label using ‘${currentValue}’, you would get an updated label when your device handler changed that attribute’s value. Additionally you could take it a step further and define multiple states per tile depending on the possible values of the attribute, and have different action’s execute.

This is all handled for you automatically when your tile targets a device capability with built in commands. Ie, device.switch, with 2 states defined for on and off, with the action, and switch.on.

1 Like

Thank you very much for this Kyse,

My understanding is the action parameter is unneeded as I do not wish for the tile to be tap-able.

For now all I’m looking for is to get the tile to appear in it’s most basic form. Everything can be static strings.

I have seen metadata in the examples but do not have it set up this way currently. When I wrap my definition, preferences and tiles it produces an error of groovy.lang.MissingMethodException: No signature of method .... However everything else in the app works perfectly without it.

Maybe my issue is simpler than I first though. In my original example "Power" is the main but what is "device.power"? should this be the object holding the sockets inputted by the user? I have tried this with no joy though.

Thank you very much for trying to help me this far. I have many years experience coding but this week is my first in groovy and SmartThings, once I have something appearing in the view I’m sure I’ll be on my way.

It’s the simulator being a POS. I just installed it and looked at it on my phone and it works fine. Unfortunately, you can’t always trust the simulator

Hi Kevin,

I probably should have said this but I’m testing on phone and not using the simulator.

Would you mind sharing the code for a bare-bones app which just adds the most basic of tiles onto a device view?

That would be really helpful and I’m sure I could take it from that point.

Created this in the IDE. Created a new blank app and just copied and pasted your code into the tiles. I’m on a Samsung S5 if that matters

 *  Hello World
 *  Copyright 2016 Kevin Tierney
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
metadata {
	definition (name: "Hello World", namespace: "tierneykev", author: "Kevin Tierney") {

	simulator {
		// TODO: define status and reply messages here

tiles {
valueTile("power", "device.power", decoration: "flat") {
state "power", label:'hello'

// parse events into attributes
def parse(String description) {
	log.debug "Parsing '${description}'"


Thank you very much!

Unfortunately when I try that I get this error:

No signature of method: script1455889453484709842926.metadata() is applicable for argument types: (script1455889453484709842926$_run_closure1) values: [script1455889453484709842926$_run_closure1@4583b58c] Possible solutions: getMetadata(), getState(), setState(java.lang.Object), metaClass(groovy.lang.Closure)

That is so weird. If I copy and paste my own working code into the IDE using “From Code”, I get the same error. If I start with “From Form” and then copy and paste , it saves fine in the from form and works without issue. Not really sure why

Both ways I unfortunately get the same error =’(