20.01.2022, 09:31
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)