![]() |
|
Tunable White template - Wiser for KNX - Printable Version +- LogicMachine 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: Tunable White template - Wiser for KNX (/showthread.php?tid=1465) |
Tunable White template - Wiser for KNX - sx3 - 28.06.2018 Hi, Is there any template for tunable white thats based on time and location? I want the color temperature of the luminaries to follow the outdoor temperature depending on time and season. Some sort of astronomical function. Is this possible? RE: Tunable White template - Wiser for KNX - iJAF - 19.01.2022 Hi! Have you found that template ? Thanks RE: Tunable White template - Wiser for KNX - admin - 20.01.2022 You can do simple linear transition between min/max temperature based on current time relative to sunrise/sunset. Code: -- minimum/maximum color temperature
tmin = 2700
tmax = 5000
-- device coordinates
latitude = 0
longitude = 0
sunrise, sunset = rscalc(latitude, longitude)
date = os.date('*t')
now = date.hour * 60 + date.min
now = math.max(now, sunrise)
now = math.min(now, sunset)
pos = (now - sunrise) / (sunset - sunrise)
color = math.floor(tmin + (tmax - tmin) * (1 - pos))
grp.checkupdate('1/1/1', color)RE: Tunable White template - Wiser for KNX - Snoolik - 28.04.2022 Made some adjustments. Now it gets true midday and goes from sunset to midday (min-max) and midday to sunset (max-min), because temperature function should be a parabola. Code: -- minimum/maximum color temperature
tmin = 2700
tmax = 5800
-- device coordinates
latitude = 0
longitude = 0
sunrise, sunset = rscalc(latitude, longitude)
midday = (sunset + sunrise) / 2
date = os.date('*t')
now = date.hour * 60 + date.min
now = math.max(now, sunrise)
now = math.min(now, sunset)
if (now < midday) then
pos = (now - sunrise) / (midday - sunrise)
color = math.floor(tmin + (tmax - tmin) * (pos))
else
pos = (now - midday) / (sunset - midday)
color = math.floor(tmin + (tmax - tmin) * (1 - pos))
end
grp.checkupdate('1/1/1', color) |