ICP-781 Fixing DTH for valve capability

Making suggested fixes

making fixes

fixing to correctly use createEvent

fixing DTH

Also adding the fortrezz water valve

refactoring a bit

adding back in debug messages

updating ocf device type

adding zigbee water valve

refactor
This commit is contained in:
Dave Hastings
2017-05-16 15:37:49 -05:00
parent eb870e5f31
commit 772cd7005a
3 changed files with 38 additions and 19 deletions

View File

@@ -12,13 +12,13 @@
* *
*/ */
metadata { metadata {
definition (name: "Fortrezz Water Valve", namespace: "smartthings", author: "SmartThings") { definition (name: "Fortrezz Water Valve", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.watervalve") {
capability "Actuator" capability "Actuator"
capability "Health Check" capability "Health Check"
capability "Valve" capability "Valve"
capability "Refresh" capability "Refresh"
capability "Sensor" capability "Sensor"
fingerprint deviceId: "0x1000", inClusters: "0x25,0x72,0x86,0x71,0x22,0x70" fingerprint deviceId: "0x1000", inClusters: "0x25,0x72,0x86,0x71,0x22,0x70"
fingerprint mfr:"0084", prod:"0213", model:"0215", deviceJoinName: "FortrezZ Water Valve" fingerprint mfr:"0084", prod:"0213", model:"0215", deviceJoinName: "FortrezZ Water Valve"
} }
@@ -62,22 +62,23 @@ def updated(){
def parse(String description) { def parse(String description) {
log.trace description log.trace description
def result = null
def cmd = zwave.parse(description) def cmd = zwave.parse(description)
if (cmd) { if (cmd) {
result = createEvent(zwaveEvent(cmd)) return zwaveEvent(cmd)
} }
log.debug "Parse returned ${result?.descriptionText}" log.debug "Could not parse message"
return result return null
} }
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) { def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
def value = cmd.value ? "closed" : "open" def value = cmd.value ? "closed" : "open"
[name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]
return [createEventWithDebug([name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]),
createEventWithDebug([name: "valve", value: value, descriptionText: "$device.displayName valve is $value"])]
} }
def zwaveEvent(physicalgraph.zwave.Command cmd) { def zwaveEvent(physicalgraph.zwave.Command cmd) {
[:] // Handles all Z-Wave commands we aren't interested in return createEvent([:]) // Handles all Z-Wave commands we aren't interested in
} }
def open() { def open() {
@@ -98,3 +99,9 @@ def ping() {
def refresh() { def refresh() {
zwave.switchBinaryV1.switchBinaryGet().format() zwave.switchBinaryV1.switchBinaryGet().format()
} }
def createEventWithDebug(eventMap) {
def event = createEvent(eventMap)
log.debug "Event created with ${event?.descriptionText}"
return event
}

View File

@@ -83,6 +83,9 @@ def parse(String description) {
} }
} }
sendEvent(event) sendEvent(event)
//handle valve attribute
event.name = "valve"
sendEvent(event)
} }
else { else {
def descMap = zigbee.parseDescriptionAsMap(description) def descMap = zigbee.parseDescriptionAsMap(description)

View File

@@ -12,7 +12,7 @@
* *
*/ */
metadata { metadata {
definition (name: "Z-Wave Water Valve", namespace: "smartthings", author: "SmartThings") { definition (name: "Z-Wave Water Valve", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.watervalve") {
capability "Actuator" capability "Actuator"
capability "Valve" capability "Valve"
capability "Polling" capability "Polling"
@@ -59,18 +59,19 @@ def updated() {
def parse(String description) { def parse(String description) {
log.trace "parse description : $description" log.trace "parse description : $description"
def result = null
def cmd = zwave.parse(description, [0x20: 1]) def cmd = zwave.parse(description, [0x20: 1])
if (cmd) { if (cmd) {
result = createEvent(zwaveEvent(cmd)) return zwaveEvent(cmd)
} }
log.debug "Parse returned ${result?.descriptionText}" log.debug "Could not parse message"
return result return null
} }
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) { def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
def value = cmd.value == 0xFF ? "open" : cmd.value == 0x00 ? "closed" : "unknown" def value = cmd.value == 0xFF ? "open" : cmd.value == 0x00 ? "closed" : "unknown"
[name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]
return [createEventWithDebug([name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]),
createEventWithDebug([name: "valve", value: value, descriptionText: "$device.displayName valve is $value"])]
} }
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) { //TODO should show MSR when device is discovered def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) { //TODO should show MSR when device is discovered
@@ -80,20 +81,22 @@ def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerS
log.debug "productTypeId: ${cmd.productTypeId}" log.debug "productTypeId: ${cmd.productTypeId}"
def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId) def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId)
updateDataValue("MSR", msr) updateDataValue("MSR", msr)
[descriptionText: "$device.displayName MSR: $msr", isStateChange: false] return createEventWithDebug([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
} }
def zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLocallyNotification cmd) { def zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLocallyNotification cmd) {
[descriptionText: cmd.toString(), isStateChange: true, displayed: true] return createEventWithDebug([descriptionText: cmd.toString(), isStateChange: true, displayed: true])
} }
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) { def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
def value = cmd.value == 0xFF ? "open" : cmd.value == 0x00 ? "closed" : "unknown" def value = cmd.value == 0xFF ? "open" : cmd.value == 0x00 ? "closed" : "unknown"
[name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]
return [createEventWithDebug([name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]),
createEventWithDebug([name: "valve", value: value, descriptionText: "$device.displayName valve is $value"])]
} }
def zwaveEvent(physicalgraph.zwave.Command cmd) { def zwaveEvent(physicalgraph.zwave.Command cmd) {
[:] // Handles all Z-Wave commands we aren't interested in return createEvent([:]) // Handles all Z-Wave commands we aren't interested in
} }
def open() { def open() {
@@ -122,3 +125,9 @@ def refresh() {
} }
delayBetween(commands,100) delayBetween(commands,100)
} }
def createEventWithDebug(eventMap) {
def event = createEvent(eventMap)
log.debug "Event created with ${event?.descriptionText}"
return event
}