My goal is to use the set kelvin fonction on a Yeelight Desktop lamp (as a test, finaly to all bulb and light from various brand all around the house)
I want to use ; setKelvin(Kelvin): Function for an adaptative Kelvin value depending on sun position
my basic LUA time script is :
Code: Select all
commandArray = {}
local mini = 100 --kelvin max range
local maxi = 0 --kelvin min range
local delta = maxi - mini
local wakeup = 60*timeofday['SunriseInMinutes']
local goodnight = 60*timeofday['SunsetInMinutes']
local periode = goodnight - wakeup
local offset = wakeup-periode/2
local color = mini
local time = os.date("*t")
local now = 60*(time.hour*60 + time.min)
if now >= wakeup and now < goodnight then
color = math.floor((maxi-delta/2)+(delta/2)*math.cos((now-offset)*2*math.pi/periode)+0.5)
end
print('color:'..color)
if otherdevices['test']~='Off' then
commandArray['OpenURL']='http://127.0.0.1:8080/json.htm?type=command¶m=setkelvinlevel&idx=24&kelvin='..color..'' '
return commandArray
As DzEvent is the futur and i try to translate this with this :
Code: Select all
local mini = 100
local maxi = 0
local delta = maxi - mini
local wakeup = 60*timeofday['SunriseInMinutes']
local goodnight = 60*timeofday['SunsetInMinutes']
local periode = goodnight - wakeup
local offset = wakeup-periode/2
local color = mini
local time = os.date("*t")
local now = 60*(time.hour*60 + time.min)
if now >= wakeup and now < goodnight then
color = math.floor((maxi-delta/2)+(delta/2)*math.cos((now-offset)*2*math.pi/periode)+0.5)
end
print('color:'..color)
return {
on = {
timer = {
'every minute',
}
},
execute = function(domoticz, timer)
domoticz.log('colordz events:'..color)
domoticz.devices('test').setKelvin(color)
end
}
Code: Select all
2021-01-23 09:41:00.274 Error: dzVents: Error: (3.1.2) Method setKelvin is not available for device "test" (deviceType=Color Switch, deviceSubType=White). If you believe this is not correct, please report.
Code: Select all
http://127.0.0.1:8080/json.htm?type=command¶m=setkelvinlevel&idx=24&kelvin=25