MQTT Bridge [device + app]

I finally decided to track down what’s causing smartthings-mqtt-bridge to not update devices added through the smartapp.

What I found in the logs is the following error gets thrown:

java.lang.NullPointerException: Cannot get property ‘value’ on null object @line 502 (doCall)

I set up a new MQTTBridge SmartApp and one by one went through each option finding those that are causing the problem. I found the following:

  • My wireless tags break Contact Sensors. (Customized Handler)
  • My custom temp/humidity dev handler breaks Switch Level. (Custom Handler) Checked the code and I only have the Switch Level capability defined but the lines that use it are commented out.
  • Echo Dots break Music Player. (Amazon Official)
  • My wireless tags break Presence Sensor (Customized Handler)
  • I can’t add anything to Switch without it breaking (I think my code changes are the problem here as I specifically modified Switch to work with my esp8266 switches running custom Homie code)

Here’s the code that’s causing the issue. I seem to remember seeing a pull request related to this. I need to go back and check. I haven’t yet tried the latest SmartApp code as I’ve added a lot to the code for it to work with my various custom devices and apps. I’m going to do that now as a new smartapp and we’ll see what happens.

Line 502:

settings[key].each {device -> attributes[attribute].push(device.displayName)

I think this is the line that’s causing the problem. I haven’t dug into why value is null since everything looks good to me with the devices that are an issue.

value: device.currentState(attribute).value

Code related to line 502:

// Update the bridge"s subscription
def updateSubscription() {
    def attributes = [
        notify: ["Contacts", "System"]
    CAPABILITY_MAP.each { key, capability ->
        capability["attributes"].each { attribute ->
            if (!attributes.containsKey(attribute)) {
                attributes[attribute] = []
            settings[key].each {device -> attributes[attribute].push(device.displayName)
                // Send current value
                    displayName: device.displayName,
                    value: device.currentState(attribute).value,
                    name: attribute
    def json = new groovy.json.JsonOutput().toJson([
        path: "/subscribe",
        body: [
            devices: attributes

    log.debug "Updating subscription: ${json}"

I’m not sure why it needs the current value to subscribe so I just commented out

value: device.currentState(attribute).value,

I have numerous virtual devices that can certainly have null values at times. There’s no reason to get/check these values during subscription that I can find.

After commenting out that line, I was able to add devices with no issues.

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.