Yeelight (execute = function) time delay

Easy to use, 100% Lua-based event scripting framework.
Post Reply
Posts: 1
Joined: Thursday 17 May 2018 13:28
Target OS: Raspberry Pi
Domoticz version:

Yeelight (execute = function) time delay

Post by Inso80 » Thursday 17 May 2018 13:47


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 = {''}
        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.."&";;     
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

Code: Select all

-- switch on for 2 minutes after a randomized delay of 1-10 minutes
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?

User avatar
Posts: 468
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands

Re: Yeelight (execute = function) time delay

Post by waaren » Thursday 17 May 2018 18:06

you could use the domoticz.variables('anotherVar').set(1).afterMin(10) approach and let the script trigger on the variable change to do the action.
Another way is to use the linux at now+10minutes command
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave , dzVents 2.4.n, Amazon echo

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests