Compare commits

..

1 Commits

Author SHA1 Message Date
Duncan McKee
b63805e17b DVCSMP-1658 Fix exception in Z-Wave Device Multichannel 2016-05-06 13:56:22 -04:00
13 changed files with 16 additions and 142 deletions

View File

@@ -1,126 +0,0 @@
/**
* Orvibo Contact Sensor
*
* Copyright Wayne Man 2016
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* Orvibo Contact Sensor Device Type
* Battery levels updates periodically, for an instant update press physical button on sensor once
* 30/04/2016 fixed fingerprint
* 09/05/2016 added heartbeat to help track if sensor is alive (recommend using a devicecheck smartapp)
*/
metadata {
definition (name: "Orvibo Contact Sensor", namespace: "a4refillpad", author: "Wayne Man") {
capability "Contact Sensor"
capability "Sensor"
capability "Battery"
fingerprint inClusters: "0000,0001,0003,0500", manufacturer: "\u6B27\u745E", model: "75a4bfe8ef9c4350830a25d13e3ab068"
}
// simulator metadata
simulator {
// status messages
status "open": "zone report :: type: 19 value: 0031"
status "closed": "zone report :: type: 19 value: 0030"
}
tiles(scale: 2) {
multiAttributeTile(name:"contact", type: "lighting", width: 6, height: 4) {
tileAttribute ("device.contact", key: "PRIMARY_CONTROL") {
attributeState("open", label:'open', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
attributeState("closed", label:'closed', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
}
valueTile("battery", "device.battery", inactiveLabel: false, width: 2, height: 2, decoration: "flat") {
state "battery", label:'${currentValue}% battery', unit:""
}
main "contact"
details(["contact", "battery"])
}
}
// Parse incoming device messages to generate events
def parse(String description) {
def name = null
def value = description
def descriptionText = null
def now = new Date()
log.debug "Parsing: ${description}"
Map map = [:]
List listMap = []
List listResult = []
if (zigbee.isZoneType19(description)) {
name = "contact"
value = zigbee.translateStatusZoneType19(description) ? "open" : "closed"
} else if(description?.startsWith("read attr -")) {
map = parseReportAttributeMessage(description)
}
def result = createEvent(name: name, value: value)
log.debug "Parse returned ${result?.descriptionText}"
// send event for heartbeat
sendEvent(name: "heartbeat", value: now)
listResult << result
if (listMap) {
for (msg in listMap) {
listResult << createEvent(msg)
}
}
else if (map) {
listResult << createEvent(map)
}
log.debug "Parse returned ${result?.descriptionText}"
return listResult
}
private Map parseReportAttributeMessage(String description) {
Map descMap = (description - "read attr - ").split(",").inject([:]) {
map, param -> def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
Map resultMap = [:]
log.info "IN parseReportAttributeMessage()"
log.debug "descMap ${descMap}"
switch(descMap.cluster) {
case "0001":
log.debug "Battery status reported"
if(descMap.attrId == "0021") {
resultMap.name = 'battery'
resultMap.value = (convertHexToInt(descMap.value) / 2)
log.debug "Battery Percentage convert to ${resultMap.value}%"
}
break
default:
log.info descMap.cluster
log.info "cluster1"
break
}
log.info "OUT parseReportAttributeMessage()"
return resultMap
}
private Integer convertHexToInt(hex) {
Integer.parseInt(hex,16)
}

View File

@@ -94,11 +94,11 @@ def parse(String description) {
def cmd = zwave.parse(description, [0x31: 1, 0x32: 1, 0x60: 3])
if (cmd) {
result = createEvent(zwaveEvent(cmd))
log.debug "Parse returned ${result?.descriptionText}"
storeGraphData(result.name, result.value)
} else {
log.debug "zwave.parse returned null command. Cannot create event"
}
log.debug "Parse returned ${result?.descriptionText}"
storeGraphData(result.name, result.value)
return result
}

View File

@@ -37,6 +37,9 @@ metadata {
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
}
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
attributeState "level", label: 'Level ${currentValue}%'
}
tileAttribute ("device.color", key: "COLOR_CONTROL") {
attributeState "color", action:"setAdjustedColor"
}

View File

@@ -38,6 +38,9 @@ metadata {
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
}
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
attributeState "level", label: 'Level ${currentValue}%'
}
tileAttribute ("device.color", key: "COLOR_CONTROL") {
attributeState "color", action:"setAdjustedColor"
}

View File

@@ -33,6 +33,9 @@ metadata {
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
}
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
attributeState "level", label: 'Level ${currentValue}%'
}
}
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, range:"(0..100)") {

View File

@@ -129,7 +129,6 @@ def refresh() {
}
def configure() {
sendEvent(name: "checkInterval", value: 1200, displayed: false)
zigbee.onOffConfig() + powerConfig() + refresh()
}

View File

@@ -311,8 +311,6 @@ def refresh() {
}
def configure() {
sendEvent(name: "checkInterval", value: 7200, displayed: false)
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
log.debug "Configuring Reporting, IAS CIE, and Bindings."
def configCmds = [

View File

@@ -323,8 +323,6 @@ def refresh() {
}
def configure() {
sendEvent(name: "checkInterval", value: 7200, displayed: false)
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
log.debug "Configuring Reporting, IAS CIE, and Bindings."

View File

@@ -441,8 +441,6 @@ def refresh() {
}
def configure() {
sendEvent(name: "checkInterval", value: 7200, displayed: false)
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
log.debug "Configuring Reporting"

View File

@@ -300,7 +300,6 @@ def getTemperature(value) {
}
def configure() {
sendEvent(name: "checkInterval", value: 7200, displayed: false)
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
log.debug "Configuring Reporting, IAS CIE, and Bindings."

View File

@@ -252,7 +252,6 @@ def refresh()
}
def configure() {
sendEvent(name: "checkInterval", value: 7200, displayed: false)
log.debug "Configuring Reporting and Bindings."
def configCmds = [

View File

@@ -110,7 +110,7 @@ def installed() {
sendEvent(name: "multilineText", value: "Line 1 YES\nLine 2 YES\nLine 3 NO")
}
def parse(String description) {
def parse() {
// This is a simulated device. No incoming data to parse.
}

View File

@@ -159,7 +159,7 @@ def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap
def formatCmd = ([cmd.commandClass, cmd.command] + cmd.parameter).collect{ String.format("%02X", it) }.join()
createEvent(name: "epEvent", value: "$cmd.sourceEndPoint:$formatCmd", isStateChange: true, displayed: false, descriptionText: "(fwd to ep $cmd.sourceEndPoint)")
} else {
zwaveEvent(encapsulatedCommand, cmd.sourceEndPoint as Integer)
zwaveEvent(encapsulatedCommand)
}
}
}
@@ -169,7 +169,7 @@ def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulat
if (encapsulatedCommand) {
state.sec = 1
def result = zwaveEvent(encapsulatedCommand)
result = result.collect {
result = [result].flatten().collect {
if (it instanceof physicalgraph.device.HubAction && !it.toString().startsWith("9881")) {
response(cmd.CMD + "00" + it.toString())
} else {