06.05.2021, 06:47
If you want to send periodical values you can use current object values instead of object logs. In this example all objects with the electricity tag are added to the CSV report.
Code:
buffer = { 'date;name;value' }
objects = grp.tag('electricity')
for _, object in ipairs(objects) do
logdate = os.date('%Y-%m-%d', math.floor(object.updatetime))
value = object.value
if type(value) == 'number' then
value = tostring(value):gsub('%.', ',')
end
buffer[ #buffer + 1 ] = string.format('%s;%s;%s',
logdate, object.name or '', tostring(value))
end
csv = table.concat(buffer, '\n')
log(csv)