Skip to content

Commit

Permalink
CHAD-5355 Zigbee lock event de-duplication (#39101)
Browse files Browse the repository at this point in the history
* Uses logic similar to what we do in z-wave locks to delay events created from lock attribute reports in case we receive a much more detailed operation event later.

If the operation event is sent first, the lock attribute event will be marked as not displayed.

* always delay lock attribute reports

* add log message

* fixup

* fixup
  • Loading branch information
greens authored Aug 4, 2020
1 parent 94885a1 commit 773d630
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,27 @@ private def parseAttributeResponse(String description) {
responseMap.value = "unknown"
responseMap.descriptionText = "Unknown state"
}
if (responseMap.value) {
/* delay this event for a second in the hopes that we get the operation event (which has more info).
If we don't get one, then it's okay to send. If we send the event with more info first, the event
with less info will be marked as not displayed
*/
log.debug "Lock attribute report received: ${responseMap.value}. Delaying event."
runIn(1, "delayLockEvent", [data : [map : responseMap]])
return [:]
}
} else {
return null
}
result << createEvent(responseMap)
return result
}

def delayLockEvent(data) {
log.debug "Sending cached lock operation: ${data.map}"
sendEvent(data.map)
}

private def parseIasMessage(String description) {
ZoneStatus zs = zigbee.parseZoneStatus(description)
def responseMap = [ name: "battery", value: zs.isBatterySet() ? 5 : 55]
Expand Down
14 changes: 14 additions & 0 deletions devicetypes/smartthings/zigbee-lock.src/zigbee-lock.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,15 @@ private def parseAttributeResponse(String description) {
responseMap.value = "unknown"
responseMap.descriptionText = "Unknown state"
}
if (responseMap.value) {
/* delay this event for a second in the hopes that we get the operation event (which has more info).
If we don't get one, then it's okay to send. If we send the event with more info first, the event
with less info will be marked as not displayed
*/
log.debug "Lock attribute report received: ${responseMap.value}. Delaying event."
runIn(1, "delayLockEvent", [data : [map : responseMap]])
return [:]
}
} else if (clusterInt == CLUSTER_DOORLOCK && attrInt == DOORLOCK_ATTR_MIN_PIN_LENGTH && descMap.value) {
def minCodeLength = Integer.parseInt(descMap.value, 16)
responseMap = [name: "minCodeLength", value: minCodeLength, descriptionText: "Minimum PIN length is ${minCodeLength}", displayed: false]
Expand All @@ -517,6 +526,11 @@ private def parseAttributeResponse(String description) {
return result
}

def delayLockEvent(data) {
log.debug "Sending cached lock operation: ${data.map}"
sendEvent(data.map)
}

/**
* Responsible for handling command responses
*
Expand Down

0 comments on commit 773d630

Please sign in to comment.