From be9c3a279d232155219dc51fb5ee832687965991 Mon Sep 17 00:00:00 2001 From: Varun Dev Date: Fri, 4 Mar 2016 15:26:20 -0600 Subject: [PATCH] MSA-922: I have a device handler I made for the DSB29-ZWUS. It started with the basic Z-wave door/window switch and I modified it because the tamper switch was not reporting at all. I've used this successfully and it has been reporting correctly to my V1 hub. I would like this added as a device so that I can try to pair one from scratch without having to edit the device handler using the web GUI. --- .../aeon-labs-ddsb29-zwus.groovy | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 devicetypes/aeon/aeon-labs-ddsb29-zwus.src/aeon-labs-ddsb29-zwus.groovy diff --git a/devicetypes/aeon/aeon-labs-ddsb29-zwus.src/aeon-labs-ddsb29-zwus.groovy b/devicetypes/aeon/aeon-labs-ddsb29-zwus.src/aeon-labs-ddsb29-zwus.groovy new file mode 100644 index 0000000..27bb507 --- /dev/null +++ b/devicetypes/aeon/aeon-labs-ddsb29-zwus.src/aeon-labs-ddsb29-zwus.groovy @@ -0,0 +1,125 @@ +/** + * Aeon Labs DSB29-ZWUS Gen2 + * + * Original Author: SmartThings + * Date: 2013-11-3 + * Modified By: Varun + * Modified Date: 2016-02-28 + * Updated original Zwave Door/Window Sensor report tamper alarm as open/close + */ + +// for the UI +metadata { + // Automatically generated. Make future change here. + definition (name: "Aeon Labs DSB29-ZWUS", namespace: "Aeon", author: "Varun") { + + capability "contact sensor" + capability "battery" + + fingerprint profileId: "0x2001", inClusters: "0x30, 0x80, 0x84, 0x71, 0x70, 0x85, 0x86, 0x72" + } + + + // simulator metadata + simulator { + // status messages + status "open": "command: 2001, payload: FF" + status "closed": "command: 2001, payload: 00" + } + + // 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" + } + valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat") { + state "battery", label:'${currentValue}% battery', unit:"" + } + + main "contact" + details(["contact", "battery"]) + } +} + +def parse(String description) { + def result = null + if (description.startsWith("Err")) { + result = createEvent(descriptionText:description, displayed:true) + } else { + def cmd = zwave.parse(description, [0x20: 1, 0x25: 1, 0x30: 1, 0x31: 5, 0x80: 1, 0x84: 1, 0x71: 3, 0x9C: 1]) + log.debug "PARSED ${cmd}" + if (cmd) { + result = zwaveEvent(cmd) + } + } + return result +} + +def sensorValueEvent(Short value) { + if (value) { + createEvent(name: "contact", value: "open", descriptionText: "$device.displayName is open") + } else { + createEvent(name: "contact", value: "closed", descriptionText: "$device.displayName is closed") + } +} + + +def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) +{ + sensorValueEvent(cmd.value) +} + +def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) +{ + sensorValueEvent(cmd.value) +} + +def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) +{ + sensorValueEvent(cmd.value) +} + +def zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv1.SensorBinaryReport cmd) +{ + sensorValueEvent(cmd.sensorValue) +} + +def zwaveEvent(physicalgraph.zwave.commands.sensoralarmv1.SensorAlarmReport cmd) +{ + sensorValueEvent(cmd.sensorState) +} + +def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) +{ + sensorValueEvent(cmd.v1AlarmLevel) +} + +def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd) +{ + def result = [createEvent(descriptionText: "${device.displayName} woke up", isStateChange: false)] + if (!state.lastbat || (new Date().time) - state.lastbat > 53*60*60*1000) { + result << response(zwave.batteryV1.batteryGet()) + result << response("delay 1200") + } + result << response(zwave.wakeUpV1.wakeUpNoMoreInformation()) + result +} + +def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) { + def map = [ name: "battery", unit: "%" ] + if (cmd.batteryLevel == 0xFF) { + map.value = 1 + map.descriptionText = "${device.displayName} has a low battery" + map.isStateChange = true + } else { + map.value = cmd.batteryLevel + } + state.lastbat = new Date().time + [createEvent(map), response(zwave.wakeUpV1.wakeUpNoMoreInformation())] +} + + +def zwaveEvent(physicalgraph.zwave.Command cmd) { + createEvent(descriptionText: "$device.displayName: $cmd", displayed: false) +}