Limit to length of "text" type in "preferences" section?


(Paul Mullen) #1

I’m trying to debug a problem in which a SmartApp seems to work properly when short sections of text are entered, but improperly when longer ones are entered. To be clear, here’s the context:

preferences {
    section {
        input "theSwitch", "capability.switch", title: "Which Simulated Switch?"
        input "theArduino","capability.switch", title: "Choose the MullenArduino"
        input "OnRelay","text", title: "Which relay(s) for ON?"
        input "OffRelay","text", title: "Which relay(s) for OFF?"
    }
}

In my application, the text can be a single number like 2 or it can be a series concatenated by commas. 0,2,29,72,57,26,6. What I have noticed is that late in the SmartApp definition, when I want to do something with the text:

def switchOnHandler(evt) {
   theArduino.remoteOn(OnRelay)
   }
   
def switchOffHandler(evt) {
   theArduino.remoteOn(OffRelay)
}

… if the text of the input is short, all is good. But if the text of the input is longer, the call to the device handler (theArduino) never occurs. I’m wondering if there’s a limit to the length of the string in the input field.


(Michael Anthony Abril) #2

Use the log to output the text to see if it successfully made it from the input field into the OnRelay/OffRelay variable. In fact, surround the text with brackets so you can be sure there are no added spaces or something:

log.trace "[" + OnRelay + "]"
log.trace "[" + OffRelay + "]"

If the text is correct, then the problem is not with the input field. Try circumventing the variable and entering your text directly into the remoteOn function:

theArduino.remoteOn("thecorrecttextstringhere")

Also, note that you have remoteOn() twice; should the second one be remoteOff()?


(Paul Mullen) #3

Well… thanks for the debug tips. Logs show that the text is being properly passed, so it has to be a problem between the SmartThings and my Arduino that receives the text. Somewhere in this call:

zigbee.smartShield(text: "A${relay}).format()

I know the relay number is right and the that the arduino never sees it. Back to the debug world. (This is why it’s fun, no?)

By the way, the repeat calls to RelayOn() in my case make sense. In short, I’m pulsing a relay that turns on or off another latching relay (one of the problems of being early adopters that put in low voltage relays to switch the AC 25 years ago). So whether I’m pulsing the On solenoid or the Off solenoid, the relay that does the pulse is temporarily On. It’s goofy, but it’s mine. :wink:

Paul