Logic Machine Forum
Philips Hue Tunable white - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Philips Hue Tunable white (/showthread.php?tid=3836)



Philips Hue Tunable white - Karaffe - 30.01.2022

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



RE: Philips Hue Tunable white - admin - 01.02.2022

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)



RE: Philips Hue Tunable white - Karaffe - 01.02.2022

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


RE: Philips Hue Tunable white - admin - 02.02.2022

Make sure you have hue user library and add require('user.hue') to the beginning of your script.


RE: Philips Hue Tunable white - Karaffe - 03.02.2022

Many Thanks
it works


RE: Philips Hue Tunable white - icuzz - 09.02.2022

Anyway to control from Mosaic 3.0 Hue RGBW-ledstripes with color temperature and RGBW?