From 8c55b6314a47019d6b3b3b31d8bc584da9d7fae1 Mon Sep 17 00:00:00 2001 From: Juan Pablo Risso Date: Wed, 4 Nov 2015 15:07:26 -0500 Subject: [PATCH] Force Level = 1% to 1 This ensures that the bulb will be able to dim to it minimum --- smartapps/smartthings/hue-connect.src/hue-connect.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/smartapps/smartthings/hue-connect.src/hue-connect.groovy b/smartapps/smartthings/hue-connect.src/hue-connect.groovy index a6246d6..14dfd95 100644 --- a/smartapps/smartthings/hue-connect.src/hue-connect.groovy +++ b/smartapps/smartthings/hue-connect.src/hue-connect.groovy @@ -24,7 +24,7 @@ definition( category: "SmartThings Labs", iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/hue.png", iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/hue@2x.png", - singleInstance: true + singleInstance: true ) preferences { @@ -623,7 +623,8 @@ def off(childDevice) { def setLevel(childDevice, percent) { log.debug "Executing 'setLevel'" - def level = Math.min(Math.round(percent * 255 / 100), 255) + def level + if (percent == 1) level = 1 else level = Math.min(Math.round(percent * 255 / 100), 255) put("lights/${getId(childDevice)}/state", [bri: level, on: percent > 0]) } @@ -648,7 +649,7 @@ def setColor(childDevice, huesettings) { def value = [sat: sat, hue: hue, alert: alert, transitiontime: transition] if (huesettings.level != null) { - value.bri = Math.min(Math.round(huesettings.level * 255 / 100), 255) + if (huesettings.level == 1) value.bri = 1 else value.bri = Math.min(Math.round(huesettings.level * 255 / 100), 255) value.on = value.bri > 0 }