Skip to content

Commit ca9a29f

Browse files
authored
ICP-3774 Refactor zigbee parsing (SmartThingsCommunity#2921)
* ICP-3774 Refactor zigbee parsing Contact sensors were reporting status when their IAS zone attribute was queried in a way we weren't expecting. Mark zigbee locks as offline pingable.
1 parent 055b19b commit ca9a29f

File tree

7 files changed

+31
-2
lines changed

7 files changed

+31
-2
lines changed

devicetypes/smartthings/nyce-open-closed-sensor.src/nyce-open-closed-sensor.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ private Map parseCatchAllMessage(String description) {
119119
log.debug "parseCatchAllMessage: msgStatus: ${msgStatus}"
120120
if (msgStatus == 0) {
121121
switch(cluster.clusterId) {
122+
case 0x0500:
123+
Map descMap = zigbee.parseDescriptionAsMap(description)
124+
// someone who understands Zigbee better than me should refactor this whole DTH to bring it up to date
125+
if (descMap?.attrInt = 0x0002) {
126+
resultMap.name = "contact"
127+
def zs = new ZoneStatus(zigbee.convertToInt(descMap.value, 16))
128+
resultMap.value = zs.isAlarm1Set() ? "open" : "closed"
129+
}
130+
break
122131
case 0x0001:
123132
log.debug 'Battery'
124133
resultMap.name = 'battery'

devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ def parse(String description) {
9696
map = parseIasMessage(description)
9797
} else {
9898
Map descMap = zigbee.parseDescriptionAsMap(description)
99-
if (descMap.clusterInt == 0x0001 && descMap.commandInt != 0x07 && descMap?.value) {
99+
if (descMap?.clusterInt == 0x0001 && descMap.commandInt != 0x07 && descMap?.value) {
100100
map = getBatteryResult(Integer.parseInt(descMap.value, 16))
101+
} else if (descMap?.clusterInt == 0x0500 && descMap.attrInt == 0x0002) {
102+
def zs = new ZoneStatus(zigbee.convertToInt(descMap.value, 16))
103+
map = translateZoneStatus(zs)
101104
} else if (descMap?.clusterInt == zigbee.TEMPERATURE_MEASUREMENT_CLUSTER && descMap.commandInt == 0x07) {
102105
if (descMap.data[0] == "00") {
103106
log.debug "TEMP REPORTING CONFIG RESPONSE: $descMap"

devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ def parse(String description) {
101101
if (descMap?.clusterInt == 0x0001 && descMap.commandInt != 0x07 && descMap?.value) {
102102
log.info "BATT METRICS - attr: ${descMap?.attrInt}, value: ${descMap?.value}, decValue: ${Integer.parseInt(descMap.value, 16)}, currPercent: ${device.currentState("battery")?.value}, device: ${device.getDataValue("manufacturer")} ${device.getDataValue("model")}"
103103
map = getBatteryResult(Integer.parseInt(descMap.value, 16))
104+
} else if (descMap?.clusterInt == 0x0500 && descMap.attrInt == 0x0002) {
105+
def zs = new ZoneStatus(zigbee.convertToInt(descMap.value, 16))
106+
map = translateZoneStatus(zs)
104107
} else if (descMap?.clusterInt == zigbee.TEMPERATURE_MEASUREMENT_CLUSTER && descMap.commandInt == 0x07) {
105108
if (descMap.data[0] == "00") {
106109
log.debug "TEMP REPORTING CONFIG RESPONSE: $descMap"

devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def parse(String description) {
127127
Map descMap = zigbee.parseDescriptionAsMap(description)
128128
if (descMap?.clusterInt == 0x0001 && descMap.commandInt != 0x07 && descMap?.value) {
129129
maps << getBatteryResult(Integer.parseInt(descMap.value, 16))
130+
} else if (descMap?.clusterInt == 0x0500 && descMap.attrInt == 0x0002) {
131+
def zs = new ZoneStatus(zigbee.convertToInt(descMap.value, 16))
132+
map = translateZoneStatus(zs)
130133
} else if (descMap?.clusterInt == zigbee.TEMPERATURE_MEASUREMENT_CLUSTER && descMap.commandInt == 0x07) {
131134
if (descMap.data[0] == "00") {
132135
log.debug "TEMP REPORTING CONFIG RESPONSE: $descMap"

devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def parse(String description) {
8888
Map descMap = zigbee.parseDescriptionAsMap(description)
8989
if (descMap?.clusterInt == 0x0001 && descMap.commandInt != 0x07 && descMap?.value) {
9090
map = getBatteryResult(Integer.parseInt(descMap.value, 16))
91+
} else if (descMap?.clusterInt == 0x0500 && descMap.attrInt == 0x0002) {
92+
def zs = new ZoneStatus(zigbee.convertToInt(descMap.value, 16))
93+
map = getContactStatus(zs.isAlarm1Set() ? "open" : "closed")
9194
} else if (descMap?.clusterInt == zigbee.TEMPERATURE_MEASUREMENT_CLUSTER && descMap.commandInt == 0x07) {
9295
if (descMap.data[0] == "00") {
9396
log.debug "TEMP REPORTING CONFIG RESPONSE: $descMap"

devicetypes/smartthings/tyco-door-window-sensor.src/tyco-door-window-sensor.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ private Map parseCatchAllMessage(String description) {
110110
def cluster = zigbee.parse(description)
111111
if (shouldProcessMessage(cluster)) {
112112
switch(cluster.clusterId) {
113+
case 0x0500:
114+
Map descMap = zigbee.parseDescriptionAsMap(description)
115+
// someone who understands Zigbee better than me should refactor this whole DTH to bring it up to date
116+
if (descMap?.attrInt = 0x0002) {
117+
def zs = new ZoneStatus(zigbee.convertToInt(descMap.value, 16))
118+
resultMap = getContactResult(zs.isAlarm1Set() ? "open" : "closed")
119+
}
120+
break
113121
case 0x0001:
114122
resultMap = getBatteryResult(cluster.data.last())
115123
break

devicetypes/smartthings/zigbee-lock.src/zigbee-lock.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def doConfigure() {
198198
log.trace "ZigBee DTH - Executing doConfigure() for device ${device.displayName}"
199199
state.configured = true
200200
// Device-Watch allows 2 check-in misses from device + ping (plus 2 min lag time)
201-
sendEvent(name: "checkInterval", value: 2 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
201+
sendEvent(name: "checkInterval", value: 2 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
202202

203203
def cmds =
204204
zigbee.configureReporting(CLUSTER_DOORLOCK, DOORLOCK_ATTR_LOCKSTATE,

0 commit comments

Comments
 (0)