multinet wrote: Saturday 18 August 2018 11:29
Hello i'm considering converting my lua scripts to dzvents
but I don't know how this lua command should be converted :
Code: Select all
val_QPluieV=os.capture('sqlite3 '..dbPath..' "select TOTAL as TOTAL from Rain_Calendar where devicerowid='..otherdevices_idx[dev_Pluviometre]..' and Date = date(\'now\', \'-1 day\')"')
This is to open the domoticz database and to execute an SQL request
Thanks !
Multinet
The os.capture does not really need to be converted. It is not a standard lua function but more a wrapper around io.popen
somewhere in your current code the function must be defined like something as
Code: Select all
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
you can just use it in dzVents as you use it now in lua (dzVents IS Lua)
The part that need to be converted to dzVents syntax is
That need to change to
Code: Select all
domoticz.devices(dev_Pluviometre).idx
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki