From bf491270a942b762b301e25b13cbce8c9c0fbc0b Mon Sep 17 00:00:00 2001 From: Zach Varberg Date: Tue, 7 Feb 2017 11:50:58 -0600 Subject: [PATCH] Properly handle setLevel for zigbee-dimmer This works around a few devices that use this DTH that do not properly handle the setLevel command. This resolves: https://smartthings.atlassian.net/browse/DPROT-242 --- .../zigbee-dimmer.src/zigbee-dimmer.groovy | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy b/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy index 7a4cc2a..bdaedf7 100644 --- a/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy +++ b/devicetypes/smartthings/zigbee-dimmer.src/zigbee-dimmer.groovy @@ -93,7 +93,13 @@ def on() { } def setLevel(value) { - zigbee.setLevel(value) + def additionalCmds = [] + if (device.getDataValue("model") == "iQBR30" && value.toInteger() > 0) { // Handle iQ bulb not following spec + additionalCmds = zigbee.on() + } else if (device.getDataValue("manufacturer") == "MRVL") { // Handle marvel stack not reporting + additionalCmds = refresh() + } + zigbee.setLevel(value) + additionalCmds } /** * PING is used by Device-Watch in attempt to reach the Device @@ -103,7 +109,7 @@ def ping() { } def refresh() { - zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() } def configure() { @@ -113,5 +119,5 @@ def configure() { sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) // OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity - zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + refresh() + zigbee.onOffConfig(0, 300) + zigbee.levelConfig() }