Need help subscribing to user defined attribute or command

Using a community supported DTH for a Centralite Keypad that has a user defined attribute named “armMode” and user defined commands including “setExitDelay” and “setDisarmed”. “armMode” shows correctly on the associated DTH Tile

When the “setExitDelay” command is executed in a Smartapp, it sets “armMode” to “exitDelay”. “setDisarmed” sets “disarmed”

setModeHelper(“disarmed”, delay)
private setModeHelper(String armMode, delay) {
sendEvent([name: “armMode”, value: armMode, data: [delay: delay as int], isStateChange: true])}

In another Smartapp I want to subscribe to changes to “armMode” but the app routine never executes (subscribe) or throws a Java error (subscrribeToCommands). So far I’ve tried various incarnations of the subscribe and subscibeToCommands without success. Anyone know how to do this, or is it even possible?

Some code I tried
subscribe (thekeypad, “armMode”, keypadHandler)
subscribeToCommand(thekeypad, “disarmed”, keypadHandler)
subscribeToCommand(thekeypad, “setDisarmed”, keypadHandler)
subscribeToCommand(thekeypad, “setExitDelay”, keypadHandler)

So many potential problems here… try logging to see where your code fails.

  1. Best suggestion: Is setModeHelper() within the SmartApp or the DTH? If within the DTH, it probably cannot be declared as private. Change it to: def setModeHelper(String armMode, delay) { . If within the SmartApp, then sendEvent() needs to be called on the device, e.g.: thekeypad.sendEvent()
  2. Did you properly declare the attribute at the top of the device handler?
  3. Have you properly declared the commands at the top of the device handler?
  4. Have you checked the device events list on the IDE to verify whether the attribute has been set? If it has been set, then the problem must be with the subscription. If it has not been set, the problem is with sending the event.
  5. Are you calling the commands correctly (e.g. thekeypad.command()?)

Thank you for your response.

Your instructions pretty much match what I eventually figured out, then released in my Keypad_ExitDelay_Talker

In my app
subscribe (thekeypads, “armMode”, ExitDelayHandler)

in the existing keypad dth
sendEvent([name: “armMode”, value: armMode, data: [delay: delay as int], isStateChange: true])

1 Like