New smartthings app now longer supports tiles so how to we add "capabilities" to our device handler

Now that the new smartthings app no longer supports the use of tiles in the old smartthings classic ide, how do we code for the new app to add capabilities to devices?
The ide documentation is all out of date since it doesnt have the documentation for coding on the new app, and when i looked into the new developer console that seems to be more for professionals who are hosting api’s on their own servers.

Any direction is appreciated.

-Logan

Hi @Logan_ST, there’s already a discussion about that somewhere in the Community about documentation and enabling developers to use/add capabilities that are not already there, or custom ones. Long story short, it’s coming some day.

I have a custom device which supports both the switch capability and the presence capability. Both show up in the new app just like in the old. I can’t configure which attribute is the primary and which are secondary like in the old app but in the device details page, everything is still there.

1 Like

Hi @Ryan780 would you be willing to post the code to your device handler?
I also really wish momentary buttons still worked. I have a handler for a yamaha receiver, but since only one of the capabilities will show up I can code like a remote in the app because tiles are no longer supported.
any suggestion to have multiple buttons in a device handler?

Hi @johnconstantelo I will look around for this in the discussion. If you happen to have it saved could you please share the link. Thank you

1 Like

It isn’t just one, it’s all of them. As long as the capability is declared, it will work to display all of the capabilities defined.

@Ryan780 but you can only use one of each capability in a device handler right?

I’m sorry, I don’t understand. How would a contact sensor have more than one contact sensor? How would turn a switch “on” if the device has more than one switch? If the device has “more than one” of each of a capability, you should create a parent/child relationship.

Hi @Ryan780 let me clarify.
I have a device handler which I am using to control a Yamaha AV receiver over lan by sending POST commands with the smarthub.
here is the code for one of the yamaha device handlers.

The momentary button tiles no longer show up, but what it used to do is have buttons for each of the different inputs, like sotify, aux, hdmi etc. and by tapping that button it would then tell the yamaha to change to that input.

Momentary buttons no longer are supported, and I cant put multiple on off switches cause that would be annoying to have to turn on and back on a switch to trigger the input change post command to send.

any suggestions to make this work better. this code is a remake of something @redloro made .

metadata {
  definition (name: "Yamaha Main", namespace: "eldridge-st", author: "eldridge") {

capability "Switch"
capability "Switch Level"
	capability "Actuator"
capability "Polling"

command "source0"
command "source1"
command "source2"
command "source3"
command "source4"
command "source5"
  }

  tiles{
standardTile("switch", "device.switch", canChangeIcon: true) {
  state("off", label:"Main Off", action:"switch.off", icon:"st.Electronics.electronics16", backgroundColor:"#79b821")
  state("on", label:"Main On", action:"switch.on", icon:"st.Electronics.electronics16", backgroundColor:"#ffffff")
}
controlTile("volume", "device.level", "slider", height: 1, width: 6, range:"(0..160)") {
  state "level", label: "Volume", action:"switch level.setLevel", backgroundColor:"#00a0dc"
}

standardTile("0", "device.source0", decoration: "flat", width: 2, height: 2) {
  state("off", label:"TV", action:"source0", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-gray.png", backgroundColor:"#ffffff")
  state("on", label:"TV", action:"source0", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-green.png", backgroundColor:"#ffffff")
}
standardTile("1", "device.source1", decoration: "flat", width: 2, height: 2) {
  state("off", label:"Spoify", action:"source1", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-gray.png", backgroundColor:"#ffffff")
  state("on", label:"Spotify", action:"source1", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-green.png", backgroundColor:"#ffffff")
}
standardTile("2", "device.source2", decoration: "flat", width: 2, height: 2) {
  state("off", label:"Sonos", action:"source2", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-gray.png", backgroundColor:"#ffffff")
  state("on", label:"Sonos", action:"source2", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-green.png", backgroundColor:"#ffffff")
}
standardTile("3", "device.source3", decoration: "flat", width: 2, height: 2) {
  state("off", label:"AUX", action:"source3", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-gray.png", backgroundColor:"#ffffff")
  state("on", label:"AUX", action:"source3", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-green.png", backgroundColor:"#ffffff")
}
standardTile("4", "device.source4", decoration: "flat", width: 2, height: 2) {
  state("off", label:"AUDIO", action:"source4", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-gray.png", backgroundColor:"#ffffff")
  state("on", label:"AUDIO", action:"source4", icon:"https://raw.githubusercontent.com/redloro/smartthings/master/images/indicator-dot-green.png", backgroundColor:"#ffffff")
}




// Defines which tile to show in the overview
main "switch"

// Defines which tile(s) to show when user opens the detailed view
details([
  "switch",
  "volume",
  "0","1","2","3","4"
])
  }
  preferences {
input name: "source0", type: "text", title: "Source 1", defaultValue: "TV"
input name: "source1", type: "text", title: "Source 2", defaultValue: "Spotify"
input name: "source2", type: "text", title: "Source 3", defaultValue: "Sonos"
input name: "source3", type: "text", title: "Source 4", defaultValue: "AUX"
input name: "source4", type: "text", title: "Source 5", defaultValue: "AUDIO"
  }
}

def on() {
  sendCommand("/main/setPower?power=on")
  sendCommand("/main/setInput?input=audio1")
  sendEvent(name: "switch", value: "on")
}
def off() {
  sendCommand("/main/setPower?power=standby")
  
  sendEvent(name: "switch", value: "off")
}

def source0() {
  setSource(0)
}
def source1() {
  setSource(1)
}
def source2() {
  setSource(2)
}
def source3() {
  setSource(3)
}
def source4() {
  setSource(4)
}
/**************************************************************************/

/**
 * Called every so often (every 5 minutes actually) to refresh the
 * tiles so the user gets the correct information.
 */
def poll() {
  refresh()
}

def parse(String description) {
  return
}

def setSource(id) {
  //log.debug "source: "+getSourceName(id)
  sendCommand("/main/setInput?input="+getSourceName(id)+"&mode=autoplay_disabled")
  setSourceTile(getSourceName(id))
}

def getSourceName(id) {
  if (settings) {
return settings."source${id}"
  } else {
return ['TV', 'Spotify', 'Sonos', 'AUX', 'AUDIO'].get(id)
  }
}

def setSourceTile(name) {
  sendEvent(name: "source", value: "Source: ${name}")
  for (def i = 0; i < 5; i++) {
if (name == getSourceName(i)) {
  sendEvent(name: "source${i}", value: "on")
}
else {
  sendEvent(name: "source${i}", value: "off")
}
  }
}


private sendCommand(body) {
  log.debug "MusicCast Receiver send command: ${body}"

  def hubAction = new physicalgraph.device.HubAction(
  headers: [HOST: "10.0.0.9:80"],
  method: "GET",
  path: "/YamahaExtendedControl/v1" + body
  )
  sendHubCommand(hubAction)
}

def zone(evt) {
  /*
  * Zone On/Off
  */
  if (evt.power) {
sendEvent(name: "switch", value: (evt.power == "on") ? "on" : "off")
  }

  /*
  * Zone Volume
  */
  if (evt.volume) {
def int volLevel = evt.volume.toInteger()
sendEvent(name: "volume", value: volLevel)
  }

  /*
  * Zone Muted
  */
  if (evt.mute) {
sendEvent(name: "muted", value: (evt.mute == true) ? "on" : "off")
  }

  /*
  * Zone Source
  */
  if (evt.input) {
setSourceTile(evt.input)
  }
}

Let me clarify, after looking at your DTH, your device does not in fact have the momentary button capability. It has button tiles. Those are very, VERY different things. A button device uses the button capability to expose those button presses to smart apps the same way that the switch capability exposes the switch attribute to smart apps. Your DTH has button tiles that you use to control the device within the ST app itself. This is not the same thing.

The capability you should add to your device is the Media Input Capability:

https://docs.smartthings.com/en/latest/capabilities-reference.html#media-input-source

Exposing that capability should give you a drop-down in the new smartthings app to select what input you want the device set to. The command that you will have to add to your DTH is “setInputSource” That will include a parameter of one of the possible input sources as defined in the capability. You can then use your DTH to respond to that input accordingly.

EDIT:
Wait…that might not work after all…I just noticed the capability is still listed as proposed…let me do some testing to see if it works.

1 Like

Nope…won’t work. Lets me save and publish it but then gives an error when I open the device in the new app. So, guess you’ll have to keep digging for a solution.

I know the Momentary capability is supported in the main component of a device as my Aqara buttons use it. I haven’t tried it in additional components but if it works in those you could use a composite device with child momentary devices. It wouldn’t be particularly pretty but it would at least have all the controls on the one page. Or if that isn’t so important then you could just use separate Momentary devices.

1 Like

@orangebucket @Ryan780 yeah I currently have separate devices that are switches and when flipped they send post messages. That’s why I want to try to get multiple momentary buttons on one device page.

Sorry I am a bit new to this ide, but willing to learn and try different suggestions out.

I will try adding multiple momentary buttons to act as input options. I also have the problem with pollingng since I don’t know how to send returns to the smartthings code so that it doesn’t keep thinking the devices are offline.

Thank you for your time.

1 Like

The button capability in the new app doesn’t allow you to tap to perform an action, it is 1-way; from device to ST. It’s possible to have multiple buttons in one page. Search ST github repo “x.com.st.d.remotecontroller” for examples.

So if the capability says “proposed” it isn’t usable yet?

I integrated the media volume capability, but I don’t see the arguments listed in the documentation yet.

Also I tries using the switch level capability, but I keep getting this error

groovy.lang.MissingMethodException: No signature of method: script_dth_4c67ed167843f2201d67fe476db6c3a598d891fe04cbaab46ad05d8e9dd8700c.setLevel() is applicable for argument types: (java.lang.Integer) values: [62]
Possible solutions: setLevel(), setDevice(java.lang.Object), setLog(java.lang.Object), setLogger(java.lang.Object), setTiles(java.util.Map)

Not sure what to do to fix it. It obviously sees I set the dimmer to “62” in the error, but it keeps giving the error.

I am able to set the value of both the new media volume capability and the switch level capability in a refresh function i made.

But I am unable to get the value from the dimmer when it is changed

I have the capability defined and I have the def setLevel(){} function defined. not sure what to do.

thank you

A couple of comments from my own headbanging here. Capabilities are not clearly defined yet. Try and you might get one to take. The list in the old and new documentation is different.

For example on your volume issue, setLevel(level) is usually for dimmers, but the music player capability used it for volume. If you want the new media volume capability you need to look at its definition for commands and attributes. It has an attribute of “volume” and has commands setVolume, volumeUp and volumeDown. For me it shows up sometimes, but I can set those values correctly.

There are so many missing pieces to the custom DTH in the new app, everyone is just guessing and trying and seeing what happens. I actually have one DTH that presents itself differently on different devices. Good luck.

Oh and Momentary buttons can be altered to work still. Done that with mine.

Because when you set the dimmer level that invokes the command setLevel. You might want to look at creating a device using the new tool rather than through the groovy IDE as any time you send learning that will really be a waste.