Switch Level integration Error

Hello,
I am getting the following error in the smartthings log when my device handler is using the switch level capability.

049f798a-e2ec-448c-96ba-378249726145 11:33:50 AM: 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)

here is the code, I am not sure why it is not seeing the setLevel def when it is clearly there.
Any help is appreacied as I am trying to avoid the use of “tiles” since I heard they were being removed in the new app.

/**
 *  SmartThings Device Handler: Yamaha MusicCast Zone
 *
 *  Author: redloro@gmail.com
 *
 *  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: "MusicCast Zone", namespace: "redloro-smartthings", author: "redloro@gmail.com") {

/**
 * List our capabilties. Doing so adds predefined command(s) which
 * belong to the capability.
 */
//capability "Music Player"
capability "Switch"
capability "Switch Level"
capability "Refresh"
capability "Polling"
//capability "Sensor"
//capability "Actuator"
	capability "Audio Volume"
	capability "Media Input Source"

main "switch"

  }
}

/**************************************************************************
 * The following section simply maps the actions as defined in
 * the metadata into onAction() calls.
 *
 * This is preferred since some actions can be dealt with more
 * efficiently this way. Also keeps all user interaction code in
 * one place.
 *
 */
def on() {
	log.debug "VERSION 2"
  log.debug "zone name:" + getZone()
  sendCommand("/${getZone()}/setPower?power=on")
  refresh()
  sendEvent(name: "switch", value: "on")
  
}
def off() {
  sendCommand("/${getZone()}/setPower?power=standby")
  refresh()
  sendEvent(name: "switch", value: "off")
 
}

//setLevel temporary until setVolume is live
def setLevel() {
	log.debug "Executing 'setLevel'"
	log.debug "LEVEL IS:" + level
}

def setVolume() {
	log.debug "Executing 'setVolume'"
sendCommand("/${getZone()}/setVolume?volume=${value}")
sendEvent(name: "volume", value: value)
	// TODO: handle 'setVolume' command
}
/*def setLevel(value) {
  sendCommand("/${getZone()}/setVolume?volume=${value}")
  sendEvent(name: "volume", value: value)
}*/

def volumeUp() {
	log.debug "Executing 'volumeUp'"
	// TODO: handle 'volumeUp' command
}

def volumeDown() {
	log.debug "Executing 'volumeDown'"
	// TODO: handle 'volumeDown' command
}


def refresh() {
  sendCommand("/${getZone()}/getStatus")
}



/**************************************************************************/

/**
 * 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("/${getZone()}/setInput?input="+getSourceName(id)+"&mode=autoplay_disabled")
  setSourceTile(getSourceName(id))
}

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)
  }

private sendCommand(body) {
  parent.sendCommand(body)
}

private refreshState(evt)
{
	log.debug "Got here! Body is: " + evt.toString()

log.debug "POWER STATUS:" + evt.power
log.debug "VOLUME state:" + evt.volume
log.debug "IMPUT state:" + evt.input
if(evt.power == "on")
{
sendEvent(name: "switch", value: "on")
}
else
{
sendEvent(name: "switch", value: "off")
}
sendEvent(name: "volume", value: evt.volume)
sendEvent(name: "level", value: evt.volume)


}

private getZone() {
  return new String(device.deviceNetworkId).tokenize('|')[2]
}

By any chance did you accidentally paste your device type handler in as a smartapp? That will produce the error that you are seeing.

@JDRoberts I dont think I put it in as a smart app. I access it to edit it from the “Device Handlers” tap, and no errors were present until I added the switchlevel capability.

1 Like

Ok, hopefully one of the grandmaster coders will stop by and be able to help you out.

I think i just figured it out
It was a dumb mistake.

I had
def setlevel()
{
}

it worked with
def setlevel(value)
{
}

thank you

3 Likes