Page 1 of 1
setRGB & dimTo in one function?
Posted: Monday 06 January 2020 9:51
by rudder66
Hi all!
I use Xiaomi Gateway 2 as a nightlight.
To do this, I use a simple dzvents script:
- Spoiler: show
Code: Select all
return {
on = {
devices = { 51 }
},
execute = function(domoticz, MOTION)
local RGB = domoticz.devices(1)
local LUXMETER = domoticz.devices(50)
if (MOTION.state == 'On' and domoticz.time.matchesRule('between 21:30 and 60 minutes after sunrise')) then
if (LUXMETER.lux <= 8 and RGB.active == false) then
RGB.setRGB(255, 54, 0)
RGB.dimTo(5)
elseif (LUXMETER.lux > 8 and RGB.active) then
RGB.switchOff()
end
elseif (MOTION.state == 'Off' and domoticz.time.matchesRule('between 21:30 and 65 minutes after sunrise')) then
if (RGB.active) then
RGB.switchOff()
end
end
end
}
All is well, but there is one problem:
when starting functions
Code: Select all
RGB.setRGB (255, 54, 0)
RGB.dimTo (5)
the nightlight is first turned on with 100% brightness, and after that the brightness decreases to the required 5%.
That is, I visually observe a flash.
How to make the nightlight turn on immediately with a given color and brightness?
Thank you!
Re: setRGB & dimTo in one function?
Posted: Monday 06 January 2020 11:06
by waaren
rudder66 wrote: ↑Monday 06 January 2020 9:51
How to make the nightlight turn on immediately with a given color and brightness?
Can you try this ? ( using setColor method of
RGBWWW deviceType)
Code: Select all
return {
on = {
devices = { 51 }
},
execute = function(domoticz, MOTION)
local RGB = domoticz.devices(1)
local LUXMETER = domoticz.devices(50)
if (MOTION.state == 'On' and domoticz.time.matchesRule('between 21:30 and 60 minutes after sunrise')) then
if (LUXMETER.lux <= 8 and RGB.active == false) then
RGB.setColor(255, 54, 0, 5)
elseif (LUXMETER.lux > 8 and RGB.active) then
RGB.switchOff()
end
elseif (MOTION.state == 'Off' and domoticz.time.matchesRule('between 21:30 and 65 minutes after sunrise')) then
if (RGB.active) then
RGB.switchOff()
end
end
end
}
Re: setRGB & dimTo in one function? [Solved]
Posted: Monday 06 January 2020 11:24
by rudder66
@waaren, you are just power! Everything works as it should!
I also need to go to the wiki page more often to get acquainted with the updates.
My offline dzvents manual did not have such a function.
Solved