This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Philips Hue Tunable white
#1
How do I get it out that I can change the color temperature by a percentage value, either via the absolute color temperature 7,600 or via a 4-bit dimming step 3,007

with this script.
Can someone help me, I'm a complete novice  Huh
Code:
function setBrightnessCT(Light_num,brightness,ct)
  if brightness == 0 then
    body_msg = '{"on":false}'
    response = sendToLight(lamp_id,body_msg)
    return response
  else
    brightness = math.floor((brightness / 1) + 0.5)
    brightness = math.floor((brightness * 2.54) + 0.5)
 
    ct = math.floor(1000000 / ct)
    ct = math.min(500, ct)
    ct = math.max(154, ct)

    --HTTP request send
    body_msg = '{"on":true,"bri":'..brightness..',"ct":'..ct..'}'
    return sendToLight(Light_num,body_msg)
  end
end
Reply
#2
You need an event script mapped to the color temperature object. Then you can call this function like this, replace 123 with your light number and 1/1/1 with the brightness control object address:
Code:
light_num = 123
brightness = grp.getvalue('1/1/1')
ct = event.getvalue()

setBrightnessCT(light_num, brightness, ct)
Reply
#3
I've now tested the whole thing.
but get the message.

User script:5: attempt to call global 'setBrightnessCT' (a nil value)
stack traceback:
User script:5: in main chunk
Reply
#4
Make sure you have hue user library and add require('user.hue') to the beginning of your script.
Reply
#5
Many Thanks
it works
Reply
#6
Anyway to control from Mosaic 3.0 Hue RGBW-ledstripes with color temperature and RGBW?
Reply


Forum Jump: