Need help with SmartThings V3 and Kwikset doorlock 916

  • Platform information:
    • Hardware: _Raspberry Pi 4
    • OS: _Openhabian
    • openHAB version: 3.0.2
  • Issue of the topic: I got my Smartthing V3 to connect with openhab; however Openhab it can’t send commands to the doorlock. This is what I see in my logs
2021-05-28 17:48:17.329 [WARN ] [rtthings.internal.SmartthingsServlet] - Error message from Smartthings: Error occured while calling action: {actionLock} for Capability: Lock with device name: SmartCode 916 Door Lock changed to: locked. Exception java.lang.IllegalArgumentException: Command 'lock' is not supported by device 0f286c4d-7263-44d8-9440-c135bf6f2844 of type 'OpenHabDeviceHandler'. Supported commands: [deviceNotification]

This is the code configuration of my thing

UID: smartthings:lock:Maindoor:ca39084e2e
label: Lock
thingTypeUID: smartthings:lock
configuration:
  smartthingsName: SmartCode 916 Door Lock
  smartthingsLocation: Mi Curramba
bridgeUID: smartthings:smartthings:b480067a8a

I would appreciate any help here or any pointer on this

@jglen, welcome to the openhab community forum :slight_smile:

Hey I was looking at that log entry, and I found where it is invoked in the OpenHabAppV2 groovy code, at line 715.

I think we need to gather more information, from the log of your SmartThings Hub. To do that we’re going to have to enable the log lines in this OpenHabAppV2. So change the code of that function so the log lines become active. It should look like this after you change the code and re-publish the app in SmartThings:

// Update a device when requested from OpenHAB
def openhabUpdateHandler(evt) {
    def json = new JsonSlurper().parseText(evt.value)
    log.debug "Received update event from openhabDevice: ${json}"

    printSettings()

    if (json.type == "notify") {
        if (json.name == "Contacts") {
            sendNotificationToContacts("${json.value}", recipients)
        } else {
            sendNotificationEvent("${json.value}")
        }
        return
    }

    // Get the CAPABILITY_MAP entry for this device type
    def capability = CAPABILITY_MAP[json.capabilityKey]
    if (capability == null) {
        log.error "No capability: \"${json.capabilityKey}\" exists, make sure there is a CAPABILITY_MAP entry for this capability."
        sendErrorResponse "Update failed device displayName of: \"${json.deviceDisplayName}\" with CAPABILITY: \"${json.capabilityKey}\" because that CAPABILTY does not exist in the SmartApp" 
        return
    }
    // Look for the device associated with this capability and perform the requested action
    settings[json.capabilityKey].each {device ->
        log.debug "openhabUpdateHandler - looking at devices with capabilityKey ${json.capabilityKey} and device{ ${device.displayName}."
        if (device.displayName == json.deviceDisplayName) {
            log.debug "openhabUpdateHandler - found device for ${json.deviceDisplayName}"
            if (capability.containsKey("action")) {
                log.debug "openhabUpdateHandler - Capability ${capability.name} with device name ${device.displayName} changed to ${json.value} using action ${capability.action}"
                def action = capability["action"]
                // Yes, this is calling the method dynamically
                try {
                    "$action"(device, json.capabilityAttribute, json.value)
                } catch (e) {
                    sendErrorResponse "Error occured while calling action: {$action} for Capability: ${capability.name} with device name: ${device.displayName} changed to: ${json.value}. Exception ${e}"
                    log.error "Error occured while calling action: {$action} for Capability: ${capability.name} with device name: ${device.displayName} changed to: ${json.value}. Exception ${e}"
                }
            }
        }
    }
}

After that, try the run the rule that unlocks the door, and go see in the SmartThingsHub log, through your browser, what comes up from these log and printSettings lines we’ve enabled.

Post the result here as a reply please.

I made the changes in code of the function to enable the logs. I also ran the script but still does not work. Please find below the logs from SmartThings.

Thanks for the assistance.

Logs

Clear

4db5c537-8436-4010-9c32-23e40db3f35a 6:49:45 PM: debug *** printSettings() done ***

4db5c537-8436-4010-9c32-23e40db3f35a 6:49:45 PM: debug **** printSettings() ****

[4db5c537-8436-4010-9c32-23e40db3f35a] 6:49:45 PM: debug Received update event from openhabDevice: {“capabilityAttribute”:“lock”,“capabilityKey”:“lock”,“deviceDisplayName”:“KwikSet Door Lock”,“path”:“update”,“value”:“locked”}

[4db5c537-8436-4010-9c32-23e40db3f35a] 6:49:45 PM: debug Received device event from Message : [capabilityAttribute:lock, capabilityKey:lock, deviceDisplayName:KwikSet Door Lock, path:update, value:locked]

[5b3e6707-2ab1-4c1b-9db1-a8a6abf12f51] 6:49:45 PM: debug Creating event with message: [capabilityAttribute:lock, capabilityKey:lock, deviceDisplayName:KwikSet Door Lock, path:update, value:locked]

[5b3e6707-2ab1-4c1b-9db1-a8a6abf12f51] 6:49:45 PM: debug Msg ‘[index:3A, mac:DCA632E92569, headers:[content-length:117, accept-encoding:gzip, post /update http/1.1:null, host:10.11.20.60:39500, user-agent:Jetty/9.4.20.v20190813, content-type:application/json], body:{“capabilityKey”: “lock”, “deviceDisplayName”: “KwikSet Door Lock”, “capabilityAttribute”: “lock”, “value”: “locked”}, header:POST /update HTTP/1.1
Accept-Encoding: gzip
User-Agent: Jetty/9.4.20.v20190813
Content-Type: application/json
Host: 10.11.20.60:39500
Content-Length: 117, data:[capabilityAttribute:lock, capabilityKey:lock, deviceDisplayName:KwikSet Door Lock, value:locked], json:[capabilityAttribute:lock, capabilityKey:lock, deviceDisplayName:KwikSet Door Lock, value:locked]]’

That’s quite peculiar, since we see some log messages but not others. Also strange the printSettings comes out empty.

@BobRak you seem to be the developer of the Groovy code. Please could you help us debug what is going on, why we don’t see the log messages even though we’ve enabled them, and why this isn’t working?

From your post dated Jun 4 it looks like the device being manipulated has Display Name of “KwikSet Door Lock”. As best I can tell this is working. Is that correct?

From your post dated May 29 it seems that you are using a different device with a name of “SmartCode 916 Door Lock”. And, from the exception

2021-05-28 17:48:17.329 [WARN ] [rtthings.internal.SmartthingsServlet] - Error message from Smartthings: Error occured while calling action: {actionLock} for Capability: Lock with device name: SmartCode 916 Door Lock changed to: locked. Exception java.lang.IllegalArgumentException: Command 'lock' is not supported by device 0f286c4d-7263-44d8-9440-c135bf6f2844 of type 'OpenHabDeviceHandler'. Supported commands: [deviceNotification]

This message means that that device does not support the command “lock”. Using the Smartthings ide click on the My Devices tab. Then select the device that corresponds to your “SmartCode 916 Door Lock”. On that screen look at the “Current States”. Does it support “lock” If not that is your problem.

Let me know what you find. If that doesn’t help I can come up with other things to try. FYI I don’t currently have and openHAB installation so that limits my ability to test things. Also, I don’t have any door locks. I’ll help all I can within my limitations.

Bob