Compare commits

...

4 Commits

Author SHA1 Message Date
Marc Ludwig
a24ab5d993 MSA-2299: connect harmony hub and smartthings 2017-10-20 13:14:22 -07:00
Vinay Rao
58a52eb195 Merge pull request #2441 from SmartThingsCommunity/staging
Rolling down staging to master
2017-10-19 22:21:25 -07:00
Vinay Rao
1ecdefe6cc Merge pull request #2427 from vaish-rahul/staging
[DVCSMP-2740] [DVCSMP-3330] [DVCSMP-3322] Yale Zigbee - Locked /
2017-10-14 10:35:00 -07:00
Rahul Vaish
cd044a714c [DVCSMP-2740] [DVCSMP-3330] [DVCSMP-3322] Yale Zigbee - Locked /
unlocked by master code event is not displayed.
Yale Zigbee lock - Unable to create the user code from Smart lock app
in previously deleted user code slot.
2017-10-13 18:41:36 +05:30
3 changed files with 13 additions and 14 deletions

View File

@@ -81,4 +81,4 @@ def ping() {
def refresh() {
log.debug "Executing 'Refresh'"
log.trace parent.poll()
}
}

View File

@@ -310,9 +310,8 @@ def validateAttributes() {
cmds += zigbee.configureReporting(CLUSTER_ALARM, ALARM_ATTR_ALARM_COUNT,
DataType.UINT16, 0, 21600, null)
}
if (state.attrSendPinOta == null || state.attrSendPinOta == 0) {
cmds += zigbee.writeAttribute(CLUSTER_DOORLOCK, DOORLOCK_ATTR_SEND_PIN_OTA, DataType.BOOLEAN, 1)
}
// DOORLOCK_ATTR_SEND_PIN_OTA is sometimes getting reset to 0. Hence, writing it explicitly to 1.
cmds += zigbee.writeAttribute(CLUSTER_DOORLOCK, DOORLOCK_ATTR_SEND_PIN_OTA, DataType.BOOLEAN, 1)
if(!device.currentValue("maxCodes")) {
cmds += zigbee.readAttribute(CLUSTER_DOORLOCK, DOORLOCK_ATTR_NUM_PIN_USERS)
}
@@ -322,9 +321,6 @@ def validateAttributes() {
if(!device.currentValue("maxCodeLength")) {
cmds += zigbee.readAttribute(CLUSTER_DOORLOCK, DOORLOCK_ATTR_MAX_PIN_LENGTH)
}
if (state.attrSendPinOta == null || state.attrSendPinOta == 0) {
cmds += zigbee.readAttribute(CLUSTER_DOORLOCK, DOORLOCK_ATTR_SEND_PIN_OTA)
}
cmds = cmds.flatten()
log.trace "validateAttributes returning commands list: " + cmds
cmds
@@ -345,7 +341,8 @@ def deleteCode(codeID) {
// Calling user code get when deleting a code because some Kwikset locks do not generate
// programming event when a code is deleted manually on the lock.
// This will also help in resolving the failure cases during deletion of a lock code.
cmds = zigbee.command(CLUSTER_DOORLOCK, DOORLOCK_CMD_CLEAR_USER_CODE, getLittleEndianHexString(codeID))
cmds = zigbee.writeAttribute(CLUSTER_DOORLOCK, DOORLOCK_ATTR_SEND_PIN_OTA, DataType.BOOLEAN, 1)
cmds += zigbee.command(CLUSTER_DOORLOCK, DOORLOCK_CMD_CLEAR_USER_CODE, getLittleEndianHexString(codeID))
cmds += requestCode(codeID)
} else {
log.warn "Zigbee DTH - Invalid input: Unable to delete slot number $codeID"
@@ -496,9 +493,6 @@ private def parseAttributeResponse(String description) {
} else if (clusterInt == CLUSTER_DOORLOCK && attrInt == DOORLOCK_ATTR_NUM_PIN_USERS && descMap.value) {
def maxCodes = Integer.parseInt(descMap.value, 16)
responseMap = [name: "maxCodes", value: maxCodes, descriptionText: "Maximum Number of user codes supported is ${maxCodes}", displayed: false]
} else if (clusterInt == CLUSTER_DOORLOCK && attrInt == DOORLOCK_ATTR_SEND_PIN_OTA && descMap.value) {
state.attrSendPinOta = Integer.parseInt(descMap.value, 16)
return null
} else {
log.trace "ZigBee DTH - parseAttributeResponse() - ignoring attribute response"
return null
@@ -548,7 +542,7 @@ private def parseCommandResponse(String description) {
if (eventSource == 0) {
def codeID = Integer.parseInt(data[3] + data[2], 16)
if (!isValidCodeID(codeID)) {
if (!isValidCodeID(codeID, true)) {
// invalid code slot number reported by lock
log.debug "Invalid slot number := $codeID"
return null
@@ -946,12 +940,17 @@ private def getCodeFromOctet(data) {
* Checks if the slot number is within the allowed limits
*
* @param codeID The code slot number
*
* @param allowMasterCode Flag to indicate if master code slot should be allowed as a valid slot
*
* @return true if valid, false if not
*/
private boolean isValidCodeID(codeID) {
private boolean isValidCodeID(codeID, allowMasterCode = false) {
def defaultMaxCodes = isYaleLock() ? 250 : 30
def minCodeId = isYaleLock() ? 1 : 0
if (allowMasterCode) {
minCodeId = 0
}
def maxCodes = device.currentValue("maxCodes") ?: defaultMaxCodes
if (codeID.toInteger() >= minCodeId && codeID.toInteger() <= maxCodes) {
return true

View File

@@ -998,4 +998,4 @@ private hubItem(hub) {
ip: hub.localIP,
port: hub.localSrvPortTCP
]
}
}