diff --git a/devicetypes/smartthings/zigbee-switch-power.src/zigbee-switch-power.groovy b/devicetypes/smartthings/zigbee-switch-power.src/zigbee-switch-power.groovy index 430b66c..a5eb0ac 100644 --- a/devicetypes/smartthings/zigbee-switch-power.src/zigbee-switch-power.groovy +++ b/devicetypes/smartthings/zigbee-switch-power.src/zigbee-switch-power.groovy @@ -51,22 +51,15 @@ metadata { // Parse incoming device messages to generate events def parse(String description) { log.debug "description is $description" - - def resultMap = zigbee.getKnownDescription(description) - if (resultMap) { - log.info resultMap - if (resultMap.type == "update") { - log.info "$device updates: ${resultMap.value}" - } - else if (resultMap.type == "power") { + def event = zigbee.getEvent(description) + if (event) { + if (event.name == "power") { def powerValue - if (device.getDataValue("manufacturer") != "OSRAM") { //OSRAM devices do not reliably update power - powerValue = (resultMap.value as Integer)/10 //TODO: The divisor value needs to be set as part of configuration - sendEvent(name: "power", value: powerValue) - } + powerValue = (event.value as Integer)/10 //TODO: The divisor value needs to be set as part of configuration + sendEvent(name: "power", value: powerValue) } else { - sendEvent(name: resultMap.type, value: resultMap.value) + sendEvent(event) } } else { diff --git a/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy b/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy index d861b95..4440054 100644 --- a/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy +++ b/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy @@ -53,16 +53,9 @@ metadata { // Parse incoming device messages to generate events def parse(String description) { log.debug "description is $description" - - def resultMap = zigbee.getKnownDescription(description) - if (resultMap) { - log.info resultMap - if (resultMap.type == "update") { - log.info "$device updates: ${resultMap.value}" - } - else { - sendEvent(name: resultMap.type, value: resultMap.value) - } + def event = zigbee.getEvent(description) + if (event) { + sendEvent(event) } else { log.warn "DID NOT PARSE MESSAGE for description : $description" diff --git a/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy b/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy index b8ad984..50f270d 100644 --- a/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy +++ b/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy @@ -73,16 +73,9 @@ metadata { // Parse incoming device messages to generate events def parse(String description) { log.debug "description is $description" - - def finalResult = zigbee.getKnownDescription(description) - if (finalResult) { - log.info finalResult - if (finalResult.type == "update") { - log.info "$device updates: ${finalResult.value}" - } - else { - sendEvent(name: finalResult.type, value: finalResult.value) - } + def event = zigbee.getEvent(description) + if (event) { + sendEvent(event) } else { log.warn "DID NOT PARSE MESSAGE for description : $description"