SmartApp Preference Input Install Error? (problem processing request)


#1

Evening everyone :wave: Currently testing out my SmartApp with some community members. I’m running into an issue where installing some devices is throwing the following error:

“There was a problem processing your request. Please try again.”

Has anyone else experienced this limit? Here is my input code:

section("Control these devices...") {
      input "Actuator", "capability.actuator", multiple: true, title: "Which actuators (duplicates OK)", required: false
      input "Sensor", "capability.sensor", multiple: true, title: "Which sensors (duplicates OK)", required: false
}

Not sure what the issue is.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

What does Live Logging in the IDE show?


#3

Nothing in live logging. I found the issue though… I was subscribing to attributes multiple times. Which for some reason was causing an error for some devices.

def attributes = []

settings.each { key, devicesInInput ->
    devicesInInput.each { device ->
        device.supportedAttributes.each { attribute ->
             attributes.push(attribute.getName())
        }
    }
}

attributes.each { attribute ->
    subscribe(Actuator, attribute, eventHandler)
    subscribe(Sensor, attribute, eventHandler)
}

To solve the issue, I added a conditional that would check first if the attribute existed in the attributes array first before pushing.

if (!attributes.contains(attribute.getName())) {
  attributes.push(attribute.getName())
}

Not sure if subscribing to Actuator and Sensor is a good pattern though, since I could be subscribing to 100+ devices. Also thanks for chiming in @tgauchat :smiley: