Yeelight (execute = function) time delay
Posted: Thursday 17 May 2018 13:47
Hi,
I have some Yeelight lamps and stripes, and use the folowing code to switch my lamp on (includes mode, color and so on)
It is triggered by a human body sensor.
I´d like to delay the time for the switch off command. Atm the HBS switches to off after 1,5min which is the maximum time, and way too fast.
I found functions on the manual as
which does not help me, as I do not toggle a device, I write the commands myself.
Only way I found is setting time as a variable (f.e. local time +10min) and create an on time event using this variable - seems to be much code and effort for a "simple" delay function .
Is there any better way to delay an execute function?
I have some Yeelight lamps and stripes, and use the folowing code to switch my lamp on (includes mode, color and so on)
Code: Select all
execute = function(domoticz, device)
IPR1 = {'192.168.178.59'}
PORT = '55443';
for n, IP in pairs(IPR1) do
runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf\",4,1,\"500,1,16711680,1, 300000,7,0,0, 300000,2,1700,1, 300000,2,1700,100 \"]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."&";;
os.execute(runcommandoff);
end
end
I´d like to delay the time for the switch off command. Atm the HBS switches to off after 1,5min which is the maximum time, and way too fast.
I found functions on the manual as
Code: Select all
-- switch on for 2 minutes after a randomized delay of 1-10 minutes
device.switchOff().withinMin(10).forMin(2)
device.close().forMin(15)
device.open().afterSec(20)
device.open().afterMin(2)
Only way I found is setting time as a variable (f.e. local time +10min) and create an on time event using this variable - seems to be much code and effort for a "simple" delay function .
Is there any better way to delay an execute function?