19.03.2019, 11:55
(19.03.2019, 09:13)admin Wrote: Add to user library:
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
You will need to map an event script to both brightness and color temperature values:
Code:require('user.hue)
lamp_id = 123
bri = grp.getvalue('1/1/1') -- 0..100%
ct = grp.getvalue('1/1/2') -- 2000K..6500K
setBrightnessCT(lamp_id, bri, ct)
Thank you very much :-)
Now it works like a charm:-)
Daniel