f.lux style light management
Posted: Thursday 27 September 2018 14:51
I tried to search on the forum but couldn't find. Has anyone got a solution to control Yeelight lamps like f.lux does with Hue. Or using f.lux API?
Code: Select all
return {
on = {
timer = { '20 minutes before sunset', '10 minutes before sunset',
'every minute between sunset and 21:30'}
},
execute = function(domoticz, roomSwitch)
local Time = require('Time')
local currentTime = Time()
Stunden = os.date("%H",os.time(currentTime))
Minuten = os.date("%M",os.time(currentTime))
GesamtMinuten = Stunden*60+Minuten -- minutes today from midnight until now
Differenz = 1290-GesamtMinuten -- time between desired EndTime of transition to WarmWhite (in minutes, calculated hour*60+minutes) and current time (in minutes)
LightTemp = -1/3*Differenz+100 -- calculation of LightTemp according to time of the day. Transition starts 5 hours (300 minutes) before desired end time
if (currentTime.matchesRule('at 07:00-21:30')) then domoticz.devices('RGB-CCT 2').setKelvin(LightTemp)
end
end
}
Code: Select all
//First send ON , sleep 100ms, then the command
Send_V6_RGBWW_On(pLed->dunit, 100);
Code: Select all
return {
on = {
device = {'RGB-CCT 2'}
},
execute = function(domoticz, roomSwitch)
local light = dz.devices('RGB-CCT 2')
local Time = require('Time')
local currentTime = Time()
-- Cancel All Commands to light
light.cancelQueuedCommands()
Stunden = os.date("%H",os.time(currentTime))
Minuten = os.date("%M",os.time(currentTime))
GesamtMinuten = Stunden*60+Minuten -- minutes today from midnight until now
Differenz = 1290-GesamtMinuten -- time between desired EndTime of transition to WarmWhite (in minutes, calculated hour*60+minutes) and current time (in minutes)
if (currentTime.matchesRule('after sunset') and light.state <> 'Off') then
for i = 1,Differenz,1 do
LightTemp = -1/3*Differenz+100 -- calculation of LightTemp according to time of the day. Transition starts 5 hours (300 minutes) before desired end time
light.setKelvin(LightTemp).afterMin(i)
end
end
end
}
Code: Select all
if (currentTime.matchesRule('after sunset') and light.state <> 'Off') then