Page 1 of 1

Lua to dzVents

Posted: Sunday 21 January 2018 22:47
by jandoedel99
I have for some days trying to convert my Lua script to a dzVents script which I use sent my live power to a ESP with a LCD.
Have been trying to run the script every 5 seconds.

Code: Select all

return {
    active  = true,
	on = {
	    timer   = {'every 5 seconds'},
     		devices = {'Power'},
	},
	
    execute = function(dz, livepower)
    local DomDevice = 'Power'
    local IP = '192.168.0.53'
    local DomValue = otherdevices_svalues[DomDevice]
    local str = DomValue
    local words = {}
    for word in str:gmatch("([^;]+)") do table.insert(words, word) end
    DomValue= words[5]
    if ((words[5]) == '0') then  
         DomValue = "-" .. words[6]
     end
    runcommand = "curl http://" .. IP .. "/control?cmd=LCD,1,1,"  ..DomValue..  " "  ;
    os.execute(runcommand);
 end
}


Re: Lua to dzVents

Posted: Sunday 21 January 2018 23:32
by Eoreh
At the beginning I suggest to read the very good documentation of dzVents.
https://www.domoticz.com/wiki/DzVents:_ ... _scripting

And there in the section see "timer trigger options" with possible conditions for timer = {}
There are no 'every 5 seconds' because domoticz does not support such an event (just like in domoticz Lua), because domotic performs events for time every 1 minute.

If you real need to call a script every 5 seconds you have to trigger a change in your device "Power" every 5 seconds, and in this case you do not need the timer section

Re: Lua to dzVents

Posted: Sunday 21 January 2018 23:46
by jandoedel99
oke thanks