"unable to send command" error from ios app

(Richard Lee) #1

Hi there-

I wrote a deviceType that supports the level capability via a slider. It seems to work fine in the IDE, even when connected there to the actual target hardware. However, when I publish the device type and attach it to the hardware via the Devices pane, when I try to set the level using the iOS app, I get an error popup on the top of the screen saying ‘unable to send command’. This device type also supports switch, which does work fine in the iOS app.

Any ideas what’s wrong?

(Andrew Urman) #2

@rdlee632 can you post your code?

(Richard Lee) #3

I redacted the ip address of my currently wide open to the world lifx light controls. Suffice to say it works fine for on/off. Also, I’m unclear about the second argument for the level capability. In the IDE, depending on the number of arguments specified, one or the other gets called. Neither get called when using the iOS app.


 *  LIFX bulb
 *  Author: smartthings@richardlee.name
 *  Date: 2014-01-28
 // for the UI
metadata {
    tiles {
        standardTile("power", "device.switch", width: 2, height: 2) {
            state "off", label: 'Off', action: "switch.on", icon: "st.switches.light.off", backgroundColor: "#ffffff", nextState: "on"
            state "on", label: 'On', action: "switch.off", icon: "st.switches.light.on", backgroundColor: "#79b821", nextState: "off"
        controlTile("levelSlider", "device.level", "slider", width: 2, height: 1, inactiveLabel: false) {
            state "level", action: "setLevel"
        valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") {
            state "level", label: 'Level ${currentValue}%'
        details(["power", "levelSlider", "level"])

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

// handle commands
def on() {
    log.debug "Executing 'on' for ${device.displayName}"
    sendEvent(name: "switch", value: "on")
    httpGet("http://<redacted>/turn/${device.displayName}/on", {})

def off() {
    log.debug "Executing 'off' for ${device.displayName}"
    sendEvent(name: "switch", value: "off")
    httpGet("http://<redacted>/turn/${device.displayName}/off", {})

def setLevel(level, dummy) {
    log.debug "Got unknown extra argument for setLevel: ${dummy}"

def setLevel(level) {
    log.debug "Executing 'setLevel(${level}) for ${device.displayName}"
    sendEvent(name: "level", value: "${level}")
    def lum = level / 100

(Andrew Urman) #4

Instead of action: "setLevel" use action: "switch level.setLevel"

(Richard Lee) #5

Thanks for the response. Some of this stuff is very poorly documented. Why should I use “switch level.setLevel” instead of just referencing the “setLevel” function defined below? Where are these rules documented, or even shown in example code?