From 590285a882b0be2afadd1e268e4fdd20294d1df2 Mon Sep 17 00:00:00 2001 From: sticks18 Date: Tue, 3 Nov 2015 22:13:51 -0500 Subject: [PATCH 1/9] Update Improved OSRAM Lightify Gardenspot RGB MA.groovy --- ...ed OSRAM Lightify Gardenspot RGB MA.groovy | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index c112b0d..f7a4a94 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -19,8 +19,11 @@ metadata { attribute "colorName", "string" attribute "switchColor", "string" + attribute "loopActive", "string" command "setAdjustedColor" + command "startLoop" + command "stopLoop" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB" @@ -80,17 +83,21 @@ tiles (scale: 2){ } } standardTile("refresh", "device.switch", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { - state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" - } - controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 6, inactiveLabel: false) { - state "level", action:"switch level.setLevel" - } + state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" + } + standardTile("loop", "device.loopActive", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { + state "Active", label:'${currentValue}', action: "stopLoop" + state "Inactive", label:'${currentValue}', action: "startLoop" + } + controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 6, inactiveLabel: false) { + state "level", action:"switch level.setLevel" + } valueTile("colorName", "device.colorName", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { - state "colorName", label: '${currentValue}' + state "colorName", label: '${currentValue}' } main(["switch"]) - details(["switch", "levelSliderControl", "colorName", "refresh"]) + details(["switch", "levelSliderControl", "colorName", "loop", "refresh"]) } } From 35a27095b2b9c6ce40f800694d86e1e0ca8bcc09 Mon Sep 17 00:00:00 2001 From: sticks18 Date: Wed, 4 Nov 2015 09:08:52 -0500 Subject: [PATCH 2/9] Test Color Loop Added color loop function and features --- ...ed OSRAM Lightify Gardenspot RGB MA.groovy | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index f7a4a94..9c71209 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -74,6 +74,7 @@ tiles (scale: 2){ attributeState "Deep Pink", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#ff007b" attributeState "Raspberry", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#ff0061" attributeState "Crimson", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#ff003b" + attributeState "Color Loop", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on" } tileAttribute ("device.color", key: "COLOR_CONTROL") { attributeState "color", action: "setAdjustedColor" @@ -163,10 +164,40 @@ def parse(String description) { } +def startLoop() { + + log.debug "activating color loop" + def cmds = [] + sendEvent(name: "level", value: state.levelValue) + def level = hex(state.levelValue * 255 / 100) + cmds << zigbeeSetLevel(level) + sendEvent(name: "switch", value: "on") + sendEvent(name: "switchColor", value: "Color Loop", displayed: false) + cmds << "delay 150" + cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {E0 02 01 0002 0000}" + sendEvent(name: "loopActive", value: "Active") + + cmds + +} + +def stopLoop() { + + log.debug "deactivating color loop" + def cmds = [ + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {80 00 00 0000 0000}", "delay 200" + "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 0", "delay 200" + "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 1", "delay 200" + "st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0" + ] + sendEvent(name: "loopActive", value: "Inactive") + + cmds + +} + def on() { log.debug "on()" - sendEvent(name: "switch", value: "on") - sendEvent(name: "switchColor", value: device.currentValue("colorName"), displayed: false) setLevel(state?.levelValue) } From 40f7e2ad6b5d05b2d83c0b8c93361c12c0a0b62a Mon Sep 17 00:00:00 2001 From: sticks18 Date: Wed, 4 Nov 2015 11:26:43 -0500 Subject: [PATCH 3/9] Fixed color loop commands, parse Fixed setup of color loop commands. Disabled parse section when colorLoop active. Set colorLoop status to ST on() green color. --- Improved OSRAM Lightify Gardenspot RGB MA.groovy | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index 9c71209..3bfdb20 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -74,7 +74,7 @@ tiles (scale: 2){ attributeState "Deep Pink", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#ff007b" attributeState "Raspberry", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#ff0061" attributeState "Crimson", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#ff003b" - attributeState "Color Loop", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on" + attributeState "Color Loop", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821" } tileAttribute ("device.color", key: "COLOR_CONTROL") { attributeState "color", action: "setAdjustedColor" @@ -105,7 +105,10 @@ tiles (scale: 2){ // Parse incoming device messages to generate events def parse(String description) { //log.info "description is $description" - if (description?.startsWith("catchall:")) { + if (device.currentValue("loopActive") == "Active") { + + } + else if (description?.startsWith("catchall:")) { if(description?.endsWith("0100") ||description?.endsWith("1001") || description?.matches("on/off\\s*:\\s*1")) { def result = createEvent(name: "switch", value: "on") @@ -174,7 +177,7 @@ def startLoop() { sendEvent(name: "switch", value: "on") sendEvent(name: "switchColor", value: "Color Loop", displayed: false) cmds << "delay 150" - cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {E0 02 01 0002 0000}" + cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {07 01 01 0200 0000}" sendEvent(name: "loopActive", value: "Active") cmds @@ -185,7 +188,7 @@ def stopLoop() { log.debug "deactivating color loop" def cmds = [ - "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {80 00 00 0000 0000}", "delay 200" + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {01 00 00 0000 0000}", "delay 200" "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 0", "delay 200" "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 1", "delay 200" "st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0" From 463a33a33474c08a1742fa91fd6bda3375ad815b Mon Sep 17 00:00:00 2001 From: sticks18 Date: Wed, 4 Nov 2015 17:57:41 -0500 Subject: [PATCH 4/9] Missing commas --- Improved OSRAM Lightify Gardenspot RGB MA.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index 3bfdb20..ee089b4 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -188,9 +188,9 @@ def stopLoop() { log.debug "deactivating color loop" def cmds = [ - "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {01 00 00 0000 0000}", "delay 200" - "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 0", "delay 200" - "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 1", "delay 200" + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {01 00 00 0000 0000}", "delay 200", + "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 0", "delay 200", + "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 1", "delay 200", "st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0" ] sendEvent(name: "loopActive", value: "Inactive") From 08e9e3c72d4960ae7417de9d0f9fca332b9a476e Mon Sep 17 00:00:00 2001 From: sticks18 Date: Sat, 5 Dec 2015 15:14:30 -0500 Subject: [PATCH 5/9] Updated --- ...ed OSRAM Lightify Gardenspot RGB MA.groovy | 56 +++++++++++++++---- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index ee089b4..9058d24 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -20,6 +20,8 @@ metadata { attribute "colorName", "string" attribute "switchColor", "string" attribute "loopActive", "string" + attribute "loopDirection", "string" + attribute "loopTime", "number" command "setAdjustedColor" command "startLoop" @@ -167,20 +169,42 @@ def parse(String description) { } -def startLoop() { +def startLoop(Map params) { + // direction either increments or decrements the hue value: "Up" will increment, "Down" will decrement - log.debug "activating color loop" - def cmds = [] - sendEvent(name: "level", value: state.levelValue) - def level = hex(state.levelValue * 255 / 100) - cmds << zigbeeSetLevel(level) - sendEvent(name: "switch", value: "on") - sendEvent(name: "switchColor", value: "Color Loop", displayed: false) - cmds << "delay 150" - cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {07 01 01 0200 0000}" - sendEvent(name: "loopActive", value: "Active") + def direction = (device.currentValue("loopDirection") != null) ? device.currentValue("loopDirection") : (device.currentValue("loopDirection") == "Down" ? "00" : "01")) + if (params.direction != null) { + direction = (params.direction == "Down" ? "00" : "01") + sendEvent(name: "loopDirection", value: params.direction ) + } + - cmds + // time parameter is the time in seconds for a full loop + def cycle = (device.currentValue("loopTime") != null ? device.currentValue("loopTime") : 2) + if (params.time != null) { + cycle = params.time + sendEvent(name:"loopTime", value: cycle) + } + def finTime = swapEndianHex(hexF(cycle, 4)) + + sendEvent(name: "switchColor", value: "Color Loop", displayed: false) + sendEvent(name: "loopActive", value: "Active") + + if (params.hue == null) { + + // start hue was not specified, so start loop from current hue updating direction and time + log.debug "activating color loop from current hue" + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {07 02 ${direction} ${finTime} 0000}" + } + else { + + // start hue was specified, so convert to enhanced hue and start loop from there + def sHue = Math.min(Math.round(params.hue * 255 / 100), 255) + finHue = swapEndianHex(hexF(sHue, 4)) + log.debug "activating color loop from specified hue" + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {0F 01 ${direction} ${finTime} ${sHue}}" + + } } @@ -395,6 +419,14 @@ private hex(value, width=2) { s } +private hexF(value, width) { + def s = new BigInteger(Math.round(value).toString()).toString(16) + while (s.size() < width) { + s = "0" + s + } + s +} + private evenHex(value){ def s = new BigInteger(Math.round(value).toString()).toString(16) while (s.size() % 2 != 0) { From 418f460c90585dff43809f09a8ebb37ba30d8ad1 Mon Sep 17 00:00:00 2001 From: sticks18 Date: Mon, 7 Dec 2015 16:10:56 -0500 Subject: [PATCH 6/9] Final touches --- ...ed OSRAM Lightify Gardenspot RGB MA.groovy | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index 9058d24..8105d36 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -26,6 +26,8 @@ metadata { command "setAdjustedColor" command "startLoop" command "stopLoop" + command "setLoopTime" + command "setDirection" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB" @@ -98,9 +100,15 @@ tiles (scale: 2){ valueTile("colorName", "device.colorName", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { state "colorName", label: '${currentValue}' } + controlTile("loopTimeControl", "device.loopTime", "slider", height: 2, width: 4, range: "1...60", inactiveLabel: false) { + state "loopTime", action: "setLoopTime" + } + standardTile("loopDir", "device.loopDirection", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { + state "default", label: '${currentValue}', action: "setDirection" + } main(["switch"]) - details(["switch", "levelSliderControl", "colorName", "loop", "refresh"]) + details(["switch", "levelSliderControl", "colorName", "loop", "refresh", "loopTimeControl", "loopDir"]) } } @@ -169,6 +177,23 @@ def parse(String description) { } +def setDirection() { + def direction = (device.currentValue("loopDirection") == "Down" ? "Up" : "Down") + sendEvent(name: "loopDirection", value: direction) + if (device.currentValue("loopActive") == "Active") { + def dirHex = (direction == "Down" ? "00" : "01") + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {02 01 ${dirHex} 0000 0000}" + } +} + +def setLoopTime(value) { + sendEvent(name:"loopTime", value: value) + if (device.currentValue("loopActive") == "Active") { + def finTime = swapEndianHex(hexF(value, 4)) + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {04 01 00 ${finTime} 0000}" + } +} + def startLoop(Map params) { // direction either increments or decrements the hue value: "Up" will increment, "Down" will decrement From e408f50c4ae03b4e91b49a6c059e91a426f84f84 Mon Sep 17 00:00:00 2001 From: sticks18 Date: Wed, 9 Dec 2015 13:15:01 -0500 Subject: [PATCH 7/9] Bug fixes Fixed custom range. Fixed startLoop issue when using device tile button. Fixed ')' issue in line 200. --- Improved OSRAM Lightify Gardenspot RGB MA.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index 8105d36..3b6bc87 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -100,7 +100,7 @@ tiles (scale: 2){ valueTile("colorName", "device.colorName", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { state "colorName", label: '${currentValue}' } - controlTile("loopTimeControl", "device.loopTime", "slider", height: 2, width: 4, range: "1...60", inactiveLabel: false) { + controlTile("loopTimeControl", "device.loopTime", "slider", height: 2, width: 4, range: "(1..60)", inactiveLabel: false) { state "loopTime", action: "setLoopTime" } standardTile("loopDir", "device.loopDirection", height: 2, width: 2, inactiveLabel: false, decoration: "flat") { @@ -197,8 +197,8 @@ def setLoopTime(value) { def startLoop(Map params) { // direction either increments or decrements the hue value: "Up" will increment, "Down" will decrement - def direction = (device.currentValue("loopDirection") != null) ? device.currentValue("loopDirection") : (device.currentValue("loopDirection") == "Down" ? "00" : "01")) - if (params.direction != null) { + def direction = (device.currentValue("loopDirection") != null ? device.currentValue("loopDirection") : (device.currentValue("loopDirection") == "Down" ? "00" : "01")) + if (params?.direction != null) { direction = (params.direction == "Down" ? "00" : "01") sendEvent(name: "loopDirection", value: params.direction ) } @@ -206,7 +206,7 @@ def startLoop(Map params) { // time parameter is the time in seconds for a full loop def cycle = (device.currentValue("loopTime") != null ? device.currentValue("loopTime") : 2) - if (params.time != null) { + if (params?.time != null) { cycle = params.time sendEvent(name:"loopTime", value: cycle) } @@ -215,7 +215,7 @@ def startLoop(Map params) { sendEvent(name: "switchColor", value: "Color Loop", displayed: false) sendEvent(name: "loopActive", value: "Active") - if (params.hue == null) { + if (params?.hue == null) { // start hue was not specified, so start loop from current hue updating direction and time log.debug "activating color loop from current hue" From e2880a9ceaaaae210f96435ce1c84542106d4774 Mon Sep 17 00:00:00 2001 From: sticks18 Date: Mon, 21 Dec 2015 15:56:01 -0500 Subject: [PATCH 8/9] Bug fixes Fixed bug in Hue value in parse. Added logging to loop commands Fixed direction logic in startLoop to return hex value Fixed hue logic in startLoop for when triggered via mobile app tile. --- ...ed OSRAM Lightify Gardenspot RGB MA.groovy | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index 3b6bc87..c42120a 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -142,7 +142,7 @@ def parse(String description) { if (descMap.cluster == "0300") { if(descMap.attrId == "0000"){ //Hue Attribute - def hueValue = Math.round(convertHexToInt(descMap.value) / 255 * 360) + def hueValue = Math.round(convertHexToInt(descMap.value) / 255 * 100) log.debug "Hue value returned is $hueValue" def colorName = getColorName(hueValue) sendEvent(name: "colorName", value: colorName) @@ -179,9 +179,11 @@ def parse(String description) { def setDirection() { def direction = (device.currentValue("loopDirection") == "Down" ? "Up" : "Down") + log.trace direction sendEvent(name: "loopDirection", value: direction) if (device.currentValue("loopActive") == "Active") { def dirHex = (direction == "Down" ? "00" : "01") + log.trace dirHex "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {02 01 ${dirHex} 0000 0000}" } } @@ -197,37 +199,41 @@ def setLoopTime(value) { def startLoop(Map params) { // direction either increments or decrements the hue value: "Up" will increment, "Down" will decrement - def direction = (device.currentValue("loopDirection") != null ? device.currentValue("loopDirection") : (device.currentValue("loopDirection") == "Down" ? "00" : "01")) - if (params?.direction != null) { + def direction = (device.currentValue("loopDirection") != null ? (device.currentValue("loopDirection") == "Down" ? "00" : "01") : "00") + log.trace direction + if (params?.direction != null) { direction = (params.direction == "Down" ? "00" : "01") sendEvent(name: "loopDirection", value: params.direction ) } - + log.trace direction // time parameter is the time in seconds for a full loop def cycle = (device.currentValue("loopTime") != null ? device.currentValue("loopTime") : 2) - if (params?.time != null) { + log.trace cycle + if (params?.time != null) { cycle = params.time sendEvent(name:"loopTime", value: cycle) } - def finTime = swapEndianHex(hexF(cycle, 4)) - + log.trace cycle + def finTime = swapEndianHex(hexF(cycle, 4)) + log.trace finTime sendEvent(name: "switchColor", value: "Color Loop", displayed: false) - sendEvent(name: "loopActive", value: "Active") + sendEvent(name: "loopActive", value: "Active") - if (params?.hue == null) { - - // start hue was not specified, so start loop from current hue updating direction and time - log.debug "activating color loop from current hue" - "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {07 02 ${direction} ${finTime} 0000}" - } - else { + if (params?.hue != null) { // start hue was specified, so convert to enhanced hue and start loop from there def sHue = Math.min(Math.round(params.hue * 255 / 100), 255) finHue = swapEndianHex(hexF(sHue, 4)) log.debug "activating color loop from specified hue" "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {0F 01 ${direction} ${finTime} ${sHue}}" + + } + else { + + // start hue was not specified, so start loop from current hue updating direction and time + log.debug "activating color loop from current hue" + "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {07 02 ${direction} ${finTime} 0000}" } From 709d115fc7be7d87cbded2c79ae43f5e0994ce13 Mon Sep 17 00:00:00 2001 From: sticks18 Date: Mon, 21 Dec 2015 16:07:12 -0500 Subject: [PATCH 9/9] Added on() to startLoop Added on() command to startLoop; otherwise command is ignored by lights. --- ...ed OSRAM Lightify Gardenspot RGB MA.groovy | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Improved OSRAM Lightify Gardenspot RGB MA.groovy b/Improved OSRAM Lightify Gardenspot RGB MA.groovy index c42120a..212b084 100644 --- a/Improved OSRAM Lightify Gardenspot RGB MA.groovy +++ b/Improved OSRAM Lightify Gardenspot RGB MA.groovy @@ -198,10 +198,9 @@ def setLoopTime(value) { def startLoop(Map params) { // direction either increments or decrements the hue value: "Up" will increment, "Down" will decrement - def direction = (device.currentValue("loopDirection") != null ? (device.currentValue("loopDirection") == "Down" ? "00" : "01") : "00") log.trace direction - if (params?.direction != null) { + if (params?.direction != null) { direction = (params.direction == "Down" ? "00" : "01") sendEvent(name: "loopDirection", value: params.direction ) } @@ -210,15 +209,20 @@ def startLoop(Map params) { // time parameter is the time in seconds for a full loop def cycle = (device.currentValue("loopTime") != null ? device.currentValue("loopTime") : 2) log.trace cycle - if (params?.time != null) { + if (params?.time != null) { cycle = params.time sendEvent(name:"loopTime", value: cycle) } log.trace cycle - def finTime = swapEndianHex(hexF(cycle, 4)) + def finTime = swapEndianHex(hexF(cycle, 4)) log.trace finTime + + def cmds = [] + cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 1 {}" + cmds << "delay 200" + sendEvent(name: "switchColor", value: "Color Loop", displayed: false) - sendEvent(name: "loopActive", value: "Active") + sendEvent(name: "loopActive", value: "Active") if (params?.hue != null) { @@ -226,17 +230,17 @@ def startLoop(Map params) { def sHue = Math.min(Math.round(params.hue * 255 / 100), 255) finHue = swapEndianHex(hexF(sHue, 4)) log.debug "activating color loop from specified hue" - "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {0F 01 ${direction} ${finTime} ${sHue}}" + cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {0F 01 ${direction} ${finTime} ${sHue}}" } else { // start hue was not specified, so start loop from current hue updating direction and time log.debug "activating color loop from current hue" - "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {07 02 ${direction} ${finTime} 0000}" + cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x300 0x44 {07 02 ${direction} ${finTime} 0000}" } - + cmds } def stopLoop() {