What does this line of code? (Zigbee zone report in Device Type)


(Adrian Lopez) #1

I’m looking at some examples of the library and I don´t understand these lines of code Type of Device Template of Open / Closed Sensor:

// status messages
status “open”: "zone report :: type: 19 value: 0031"
status “closed”: “zone report :: type: 19 value: 0030”

================
and this one too…

value = zigbee.translateStatusZoneType19(description) ? “open” : “closed”

Here is the full code:

metadata {
	// Automatically generated. Make future change here.
	definition (name: "Open/Closed Sensor", namespace: "smartthings", author: "SmartThings") {
		capability "Contact Sensor"
		capability "Sensor"

		fingerprint profileId: "0104", deviceId: "0402", inClusters: "0000,0001,0003,0009,0500", outClusters: "0000"
	}

	// simulator metadata
	simulator {
		// status messages
		status "open":   "zone report :: type: 19 value: 0031"
		status "closed": "zone report :: type: 19 value: 0030"
	}

	// UI tile definitions
	tiles {
		standardTile("contact", "device.contact", width: 2, height: 2) {
			state "open", label: '${name}', icon: "st.contact.contact.open", backgroundColor: "#ffa81e"
			state "closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#79b821"
		}

		main "contact"
		details "contact"
	}
}

// Parse incoming device messages to generate events
def parse(String description) {
	def name = null
	def value = description
	if (zigbee.isZoneType19(description)) {
		name = "contact"
		value = zigbee.translateStatusZoneType19(description) ? "open" : "closed"
	}
	
	def result = createEvent(name: name, value: value)
	log.debug "Parse returned ${result?.descriptionText}"
	return result
}

#2

Are you asking why a zigbee device has a “zone report”?

It’s part of the zigbee Home Automation profile, which allows for devices like sensors to self identify as IAS (intruder alarm system) devices, which report by zone.

Zwave doesn’t have the same concept built into the protocol.

See: