Duplicate Attributes When Using Lock and Lock Codes Attributes


(Paul) #1

The Zwave Lock Device Type handler uses both Lock and Lock Codes capabilities. This results in duplicate “lock” attributes and duplicate commands “lock” and “unlock” being defined.

Will this cause an issue?


(Joshua Lyon (SharpTools.io Dashboard)) #2

Can you provide a bit more detail on what you are trying to do?

Depending on your particular use-case, you could filter down to the unique devices (or unique attributes):

([] + locks + lockCodes)?.findAll()?.unique { it.id }
// where locks and lockCodes are a set of devices (such as from inputs)

(Paul) #3

It was more surprise to find that the device had multiple attributes with the same name rather than trying to accomplish anything.

Looking at the detailed description of Capabilities https://graph.api.smartthings.com/ide/doc/capabilities, I realized that Lock and Lock Codes define the same attribute ‘lock’ and methods ‘lock()’ and ‘unlock()’.

This is the code I use to list the attributes

def mydeviceState = ""
def cr = false
mydevice.supportedAttributes.each {
    if (cr) mydeviceState += "\n"
    def myvalue = mydevice.currentValue("$it")
	mydeviceState += "$it: $myvalue"
    cr = true
}

I assume that mydevice.currentValue("$it") is picking up the value of the first ‘lock’ attribute and not the second.