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!