Hi,
I've been looking to find a way to mimic a dawn awakening using a RGB strip driven by a fibaro RGB module
@petergebruers provided some RBG / HSL translation and I've been working on the colour sequence that is stored in an array
It's essentially burnt orange -> yellow -> blue'ish -> almost white
There area few of the transitions I am not 100% happy with but I was looking for a few people to test what I have done to date and see if I am on the right path
The scene has a sleep of 1 second but in reality I'd probably have it close to 10 or 15 which would give an overall start to finish time of -10 minutes to aid a gradual wakeup
Comment out line 7 if you don't use a HomeTable
Line 61 contains the reference to the RGB strip, amend as required.
@andyp - You expressed an interest in this before
All feedback welcome - Feel free to tweak the colors or just pass back comments
Thanks
-f
-- DAWN SIMULATOR USING AN RGB STRIP
-- THANKS TO petergebruers FOR THE BULK OF THE CODE
-- BETA
--[[
%% properties
%% events
%% globals
--]]
local jT = json.decode(fibaro:getGlobalValue("HomeTable"))
--Hue_2_RGB( v1, v2, vH )
function Hue_2_RGB(v1, v2, vH)
if ( vH < 0 ) then vH = vH + 1 end
if ( vH > 1 ) then vH = vH - 1 end
if ( ( 6 * vH ) < 1 ) then return ( v1 + ( v2 - v1 ) * 6 * vH ) end
if ( ( 2 * vH ) < 1 )then return ( v2 ) end
if ( ( 3 * vH ) < 2 ) then return ( v1 + ( v2 - v1 ) * ( ( 2 / 3 ) - vH ) * 6 ) end
return ( v1 )
end
function RGB(H,S,L)
if s==0 then
return L*255,L*255,L*255
end
local var_2
if ( L < 0.5 ) then
var_2 = L * ( 1 + S )
else
var_2 = ( L + S ) - ( S * L )
end
local var_1 = 2 * L - var_2
return
255 * Hue_2_RGB( var_1, var_2, H + ( 1 / 3 ) ) ,
255 * Hue_2_RGB( var_1, var_2, H ),
255 * Hue_2_RGB( var_1, var_2, H - ( 1 / 3 ) )
end
local R,G,B=RGB(120,0.5,0.5)
fibaro:debug("R "..R.." G "..G.." B "..B)
R,G,B=RGB(120,0,0.5)
fibaro:debug("R "..R.." G "..G.." B "..B)
local dawnHSL={
{0,0,0}, -- turn off.
{0.03,0.67,0.012}, {0.04,0.68,0.013}, {0.06,0.69,0.014}, {0.08,0.70,0.015}, {0.09,0.71,0.016}, {0.10,0.73,0.017}, {0.12,0.75,0.018},
{0.13,0.77,0.019}, {0.15,0.79,0.020}, {0.19,0.83,0.022}, {0.20,0.84,0.023}, {0.21,0.86,0.024}, {0.22,0.87,0.023}, {0.23,0.89,0.026},
{0.25,0.91,0.028}, {0.41,0.90,0.033}, {0.41,0.88,0.034}, {0.41,0.86,0.035}, {0.42,0.85,0.036}, {0.43,0.83,0.037}, {0.44,0.81,0.038},
{0.44,0.79,0.038}, {0.44,0.78,0.040}, {0.45,0.77,0.041}, {0.45,0.75,0.042}, {0.44,0.73,0.043}, {0.46,0.72,0.044}, {0.46,0.70,0.045},
{0.47,0.69,0.046}, {0.47,0.67,0.047}, {0.48,0.66,0.048}, {0.49,0.63,0.049}, {0.50,0.61,0.050}, {0.51,0.58,0.051}, {0.52,0.56,0.052},
{0.53,0.53,0.053}, {0.54,0.51,0.054}, {0.55,0.48,0.055}, {0.56,0.46,0.056}, {0.58,0.44,0.057}, {0.59,0.42,0.058}, {0.59,0.39,0.059},
{0.59,0.37,0.060}, {0.60,0.35,0.061}, {0.60,0.32,0.062}, {0.60,0.28,0.063}, {0.60,0.24,0.064}, {0.61,0.22,0.065}, {0.61,0.20,0.066},
{0.61,0.18,0.067}, {0.61,0.16,0.068}, {0.61,0.15,0.069}, {0.61,0.14,0.070}, {0.61,0.13,0.071}, {0.61,0.12,0.072}, {0.60,0.11,0.073},
{0.60,0.10,0.074}, {0.60,0.09,0.075}, {0.60,0.08,0.076}, {0.60,0.07,0.077}, {0.60,0.05,0.078}, {0.60,0.05,0.079}, {0.60,0.05,0.080},
{0.60,0.05,0.082}, {0.60,0.04,0.083}, {0.60,0.03,0.084}, {0.60,0.02,0.085}, {0.60,0.01,0.086}, {0.60,0.02,0.087}, {0.60,0.01,0.088},
}
fibaro:debug(string.format("R G B "))
for k,v in pairs(dawnHSL) do
local R,G,B=RGB(v[1],v[2],v[3])
fibaro:debug(string.format("%05.1f %05.1f %05.1f",R,G,B))
fibaro:call(jT.master_bedroom.LEDLight, "setColor",math.floor(R+0.5),
math.floor(G+0.5), math.floor(B+0.5), "0")
fibaro:sleep(1000)
end