From 445c115c1456743198e938f511a113f96deb2948 Mon Sep 17 00:00:00 2001 From: Juan Pablo Risso Date: Fri, 20 Jan 2017 17:49:15 -0500 Subject: [PATCH 1/3] DVCSMP-2324 - Centralite Thermostat handle multiple attributes (#1606) - Curly braces - remove parseDescriptionAsMap - descMap to it - Appended to the result list - Convert to list and appended --- .../centralite-thermostat.groovy | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/devicetypes/smartthings/centralite-thermostat.src/centralite-thermostat.groovy b/devicetypes/smartthings/centralite-thermostat.src/centralite-thermostat.groovy index a92839f..394ac2d 100644 --- a/devicetypes/smartthings/centralite-thermostat.src/centralite-thermostat.groovy +++ b/devicetypes/smartthings/centralite-thermostat.src/centralite-thermostat.groovy @@ -81,51 +81,47 @@ metadata { // parse events into attributes def parse(String description) { log.debug "Parse description $description" - def map = [:] - if (description?.startsWith("read attr -")) { - def descMap = parseDescriptionAsMap(description) - log.debug "Desc Map: $descMap" - if (descMap.cluster == "0201" && descMap.attrId == "0000") { + List result = [] + def descMap = zigbee.parseDescriptionAsMap(description) + log.debug "Desc Map: $descMap" + List attrData = [[cluster: descMap.cluster ,attrId: descMap.attrId, value: descMap.value]] + descMap.additionalAttrs.each { + attrData << [cluster: descMap.cluster, attrId: it.attrId, value: it.value] + } + attrData.each { + def map = [:] + if (it.cluster == "0201" && it.attrId == "0000") { log.debug "TEMP" map.name = "temperature" - map.value = getTemperature(descMap.value) + map.value = getTemperature(it.value) map.unit = temperatureScale - } else if (descMap.cluster == "0201" && descMap.attrId == "0011") { + } else if (it.cluster == "0201" && it.attrId == "0011") { log.debug "COOLING SETPOINT" map.name = "coolingSetpoint" - map.value = getTemperature(descMap.value) + map.value = getTemperature(it.value) map.unit = temperatureScale - } else if (descMap.cluster == "0201" && descMap.attrId == "0012") { + } else if (it.cluster == "0201" && it.attrId == "0012") { log.debug "HEATING SETPOINT" map.name = "heatingSetpoint" - map.value = getTemperature(descMap.value) + map.value = getTemperature(it.value) map.unit = temperatureScale - } else if (descMap.cluster == "0201" && descMap.attrId == "001c") { + } else if (it.cluster == "0201" && it.attrId == "001c") { log.debug "MODE" map.name = "thermostatMode" - map.value = getModeMap()[descMap.value] - } else if (descMap.cluster == "0202" && descMap.attrId == "0000") { + map.value = getModeMap()[it.value] + } else if (it.cluster == "0202" && it.attrId == "0000") { log.debug "FAN MODE" map.name = "thermostatFanMode" - map.value = getFanModeMap()[descMap.value] + map.value = getFanModeMap()[it.value] } + if (map) { + result << createEvent(map) + } + log.debug "Parse returned $map" } - - def result = null - if (map) { - result = createEvent(map) - } - log.debug "Parse returned $map" return result } -def parseDescriptionAsMap(description) { - (description - "read attr - ").split(",").inject([:]) { map, param -> - def nameAndValue = param.split(":") - map += [(nameAndValue[0].trim()):nameAndValue[1].trim()] - } -} - def getModeMap() { [ "00":"off", "03":"cool", From c650047f318566ce87bdf88f174c9c4498b48445 Mon Sep 17 00:00:00 2001 From: Vinay Rao Date: Wed, 25 Jan 2017 04:12:42 -0800 Subject: [PATCH 2/3] ICP-203 Adding Light Capability to hue lights --- devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy | 1 + devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy | 1 + devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy | 3 ++- .../hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy b/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy index ae48f0d..2d6f063 100644 --- a/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy +++ b/devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy @@ -17,6 +17,7 @@ metadata { capability "Refresh" capability "Sensor" capability "Health Check" + capability "Light" command "setAdjustedColor" command "reset" diff --git a/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy b/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy index 143b0b3..b214b42 100644 --- a/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy +++ b/devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy @@ -18,6 +18,7 @@ metadata { capability "Refresh" capability "Sensor" capability "Health Check" + capability "Light" command "setAdjustedColor" command "reset" diff --git a/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy b/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy index d855d38..c221593 100644 --- a/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy +++ b/devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy @@ -14,7 +14,8 @@ metadata { capability "Switch" capability "Refresh" capability "Sensor" - capability "Health Check" + capability "Health Check" + capability "Light" command "refresh" } diff --git a/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy b/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy index 718ed57..6d1fa16 100644 --- a/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy +++ b/devicetypes/smartthings/hue-white-ambiance-bulb.src/hue-white-ambiance-bulb.groovy @@ -16,6 +16,7 @@ metadata { capability "Switch" capability "Refresh" capability "Health Check" + capability "Light" command "refresh" } From be2e19e4069cd65bfc5317befe943bb4b96a8ff9 Mon Sep 17 00:00:00 2001 From: Zach Varberg Date: Thu, 26 Jan 2017 10:24:26 -0600 Subject: [PATCH 3/3] Manually refresh on/off status after setLevel This is because ZLL bulbs do not report or allow for configuration of reporting of attributes. As a result if we change a value, we have to manually call a read of that attribute to update our status. This is a part of: https://smartthings.atlassian.net/browse/DPROT-227 --- devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy | 2 +- .../smartthings/zll-dimmer-bulb.src/zll-dimmer-bulb.groovy | 2 +- devicetypes/smartthings/zll-rgb-bulb.src/zll-rgb-bulb.groovy | 2 +- devicetypes/smartthings/zll-rgbw-bulb.src/zll-rgbw-bulb.groovy | 2 +- .../zll-white-color-temperature-bulb.groovy | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy b/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy index 26fa1b9..58a8184 100644 --- a/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy +++ b/devicetypes/smartthings/cree-bulb.src/cree-bulb.groovy @@ -82,7 +82,7 @@ def on() { } def setLevel(value) { - zigbee.setLevel(value) + ["delay 500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report + zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report } /** diff --git a/devicetypes/smartthings/zll-dimmer-bulb.src/zll-dimmer-bulb.groovy b/devicetypes/smartthings/zll-dimmer-bulb.src/zll-dimmer-bulb.groovy index cce0862..a0568e7 100644 --- a/devicetypes/smartthings/zll-dimmer-bulb.src/zll-dimmer-bulb.groovy +++ b/devicetypes/smartthings/zll-dimmer-bulb.src/zll-dimmer-bulb.groovy @@ -89,7 +89,7 @@ def on() { } def setLevel(value) { - zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report + zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report } def refresh() { diff --git a/devicetypes/smartthings/zll-rgb-bulb.src/zll-rgb-bulb.groovy b/devicetypes/smartthings/zll-rgb-bulb.src/zll-rgb-bulb.groovy index 5988334..ad591e1 100644 --- a/devicetypes/smartthings/zll-rgb-bulb.src/zll-rgb-bulb.groovy +++ b/devicetypes/smartthings/zll-rgb-bulb.src/zll-rgb-bulb.groovy @@ -115,7 +115,7 @@ def refreshAttributes() { } def setLevel(value) { - zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report + zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report } def setColor(value){ diff --git a/devicetypes/smartthings/zll-rgbw-bulb.src/zll-rgbw-bulb.groovy b/devicetypes/smartthings/zll-rgbw-bulb.src/zll-rgbw-bulb.groovy index 5d9e700..ce1ac65 100644 --- a/devicetypes/smartthings/zll-rgbw-bulb.src/zll-rgbw-bulb.groovy +++ b/devicetypes/smartthings/zll-rgbw-bulb.src/zll-rgbw-bulb.groovy @@ -135,7 +135,7 @@ def setColorTemperature(value) { } def setLevel(value) { - zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report + zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report } def setColor(value){ diff --git a/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy b/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy index 98ddddd..737a933 100644 --- a/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy +++ b/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy @@ -90,7 +90,7 @@ def on() { } def setLevel(value) { - zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() + zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() } def refresh() {