Lua to dzVents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
jandoedel99
Posts: 12
Joined: Tuesday 18 April 2017 21:55
Target OS: -
Domoticz version:
Contact:

Lua to dzVents

Post 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
}

Eoreh
Posts: 65
Joined: Tuesday 13 October 2015 13:50
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Poland
Contact:

Re: Lua to dzVents

Post 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
jandoedel99
Posts: 12
Joined: Tuesday 18 April 2017 21:55
Target OS: -
Domoticz version:
Contact:

Re: Lua to dzVents

Post by jandoedel99 »

oke thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest