Page 1 of 1

[LUA] asynchronous OpenURL call

Posted: Sunday 28 March 2021 16:57
by tmunzer
Hi All,
After waiting a long time (nearly 2 years!) I upgraded - clean reinstall then reloading settings- Domoticz (running on a Armbian Buster Sunveil R69 TV Box).

Everything went fine, except for one LUA internal script. That script updates an LCD2004 panel associated with an ESP2866 Esp Easy., using a CommandArray with 5 OpenURL calls. The first one clearing the panel, the next four writing the four text lines.

With my old Domoticz version, successives OpenURL calls were synchronous and result was deterministic, but with last stable build, they looks like asynchronous : so the CLEAR command sent to the panel is sometimes executed first (with expected result) but most of the time it's not and lines written before the CLEAR are.. cleared!

Code: Select all

        commandArray[1]={['OpenURL'] = baseurlESPEasy..'CMD,clear' }
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',1,1,"'..space..space..jour..'"'}
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',2,1,"'..space..space..space..'DNS'..space..space..space..space..space..space..twopoints..space..otherdevices["Dns Resolution"]..'"'}
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',3,1,"'..space..space..space..'Internet'..space..twopoints..space..otherdevices["Google"]..'"'}
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',4,1,"'..space..space..space..'Serveur'..space..space..twopoints..space..otherdevices["Tatooine"]..'"'}
That code worked with my previous Domoticz version and still works sometimes, but is it possible to force synchronous OpenURL calls in LUA internal scripts ?

Re: [LUA] asynchronous OpenURL call

Posted: Sunday 28 March 2021 19:38
by waaren
tmunzer wrote: Sunday 28 March 2021 16:57 Is it possible to force synchronous OpenURL calls in LUA internal scripts ?
No.

but you could use the delay functionality of the event system.

Code: Select all

commandArray = {}

        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..'CMD,clear' }
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',1,1,"'..space..space..jour..'"' .. ' AFTER 0.2' }
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',2,1,"'..space..space..space..'DNS'..space..space..space..space..space..space..twopoints..space..otherdevices["Dns Resolution"]..'"' .. ' AFTER 0.4' }
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',3,1,"'..space..space..space..'Internet'..space..twopoints..space..otherdevices["Google"]..'"' .. ' AFTER 0.6' }
        commandArray[#commandArray + 1]={['OpenURL'] = baseurlESPEasy..',4,1,"'..space..space..space..'Serveur'..space..space..twopoints..space..otherdevices["Tatooine"]..'"' .. ' AFTER 0.8' }
        
return commandArray

Re: [LUA] asynchronous OpenURL call

Posted: Sunday 28 March 2021 19:54
by tmunzer
waaren wrote: Sunday 28 March 2021 19:38 but you could use the delay functionality of the event system.
Thank you. It does not work 100% as before upgrade but it's OK for me. Before asking for help, I did a quite extensive search looking for OpenURL syntax in Domoticz documentation, but found nothing related to LUA syntax, only for dzVents.

Re: [LUA] asynchronous OpenURL call

Posted: Sunday 28 March 2021 20:05
by waaren
tmunzer wrote: Sunday 28 March 2021 19:54 I did a quite extensive search looking for OpenURL syntax in Domoticz documentation, but found nothing related to LUA syntax, only for dzVents.
Understand. Will add something to the wiki.