In Blocky I run a LUA script. I want to run this script with a delay of x seconds.
Is this possible?
Blocky: Run LUA script with a delay of x seconds
Moderators: leecollings, remb0
-
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
-
- Posts: 20
- Joined: Thursday 25 May 2017 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version: current
- Contact:
Blocky: Run LUA script with a delay of x seconds
You could change the lua script so it starts with a delay/sleep. Here are some suggestions on building a sleep function in lua: http://lua-users.org/wiki/SleepFunction
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Blocky: Run LUA script with a delay of x seconds
Probably not an ideal solution as the event system in domoticz is single threaded. So it will have to wait until the lua script with the delay is finished.leonmoonen wrote: ↑Sunday 22 July 2018 11:21You could change the lua script so it starts with a delay/sleep. Here are some suggestions on building a sleep function in lua: http://lua-users.org/wiki/SleepFunctionRitmeester wrote: ↑Sunday 22 July 2018 8:34 In Blocky I run a LUA script. I want to run this script with a delay of x seconds.
Is this possible?
Better to use a workaround by creating a virtual device or variable that you switch / set with the afterSeconds option and let that device / var trigger the next script.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 20
- Joined: Thursday 25 May 2017 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version: current
- Contact:
Re: Blocky: Run LUA script with a delay of x seconds
Wow, I had fully expected that such ‘secondary’ scripts (i.e., started in a event handling script like blockly) would be executed on the background...
Is there a reason not to do so (except if you’d want to get a value back)?
Is there a reason not to do so (except if you’d want to get a value back)?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Blocky: Run LUA script with a delay of x seconds
If it is external script (so started from os level) you can use the OS mechanism for running it in the background. So in linux you could start it with a trailing &.leonmoonen wrote: ↑Sunday 22 July 2018 11:52 Wow, I had fully expected that such ‘secondary’ scripts (i.e., started in a event handling script like blockly) would be executed on the background...
Is there a reason not to do so (except if you’d want to get a value back)?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Blocky: Run LUA script with a delay of x seconds
Thank you all for the answers. I didn’t know of this “Single Threaded” so I made a virtual switch and let this switch do the job.
All is working perfect now.
EDIT: Extra info.
The sleep command in LUA wil generate this error message:
All is working perfect now.
EDIT: Extra info.
The sleep command in LUA wil generate this error message:
Code: Select all
Error: EventSystem: Warning!, lua script Post Box Switch has been running for more than 10 seconds
Who is online
Users browsing this forum: No registered users and 1 guest