return { on = { timer = { 'at *:00' }, }, logging = { level = domoticz.LOG_INFO, marker = 'Test', }, execute = function(domoticz, item) -- auto lookup or manually fill in wanted Power and Gas idx PowerIDX = domoticz.devices('Power').idx GasIDX = domoticz.devices('Gas').idx -- fill in output path of CSV files, like '/home/pi/share' CSVpath = '/volume1/tmp' -- most domoticz systems create files as root/root, some systems only have read rights for group -- if you want the newly created files belong to another group like 'pi', enter here: NewGroup = '' -- NOTHING TO ADAPT FROM HERE -- -- create meters information line Meters='power&gas;dmtz1;' .. domoticz.time.getISO() .. ';' device = domoticz.devices(PowerIDX) Meters=Meters .. device.usage1 .. ';' .. device.return1 .. ';' Meters=Meters .. device.usage2 .. ';' .. device.return2 .. ';' device = domoticz.devices(GasIDX) Meters=Meters .. device.counter -- check if on month break yesterday = domoticz.time.addMinutes(-121) today = domoticz.time.addMinutes(61) if ( yesterday.month == today.month ) then csvfile = CSVpath .. '/DPhourly-' .. today.year .. '-' .. today.month .. '.csv' csvhandle = assert(io.open(csvfile, "a")) csvhandle:write(Meters .. '\n') csvhandle:close() else csvfile = CSVpath .. '/DPhourly-' .. yesterday.year .. '-' .. yesterday.month .. '.csv' csvhandle = assert(io.open(csvfile, "a")) csvhandle:write(Meters .. '\n') csvhandle:close() csvfile = CSVpath .. '/DPhourly-' .. today.year .. '-' .. today.month .. '.csv' csvhandle = assert(io.open(csvfile, "a")) csvhandle:write(Meters .. '\n') csvhandle:close() if ( NewGroup ~= '' ) then os.execute('chgrp ' .. NewGroup .. ' ' .. csvfile) end end end }