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:
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 switch.off, and switch.on.
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
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:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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'
}
main(["power"])
details(["power"])
}
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
}
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