I added line 14
Grazie
Code: Select all
return {
on = {
devices = {
'PZEM'
}
},
data = { lastExecutionTime = { initial = 0 }},
execute = function(dz, item)
dz.log('Device ' .. item.name .. ' was changed', dz.LOG_INFO)
pushToInfluxdb('67','0',device.rawData[1]) --Aggiunto Riga 14
local function pushToInfluxdb(idx , nValue, rawData )
local sValue = table.concat(rawData,';')
local nValue = nValue or 0
dz.log('idx: ' .. idx, dz.LOG_DEBUG)
dz.log('nValue: ' .. nValue, dz.LOG_DEBUG)
dz.log('sValue: ' .. sValue, dz.LOG_DEBUG)
local url = dz.settings['Domoticz url'] .. '/json.htm?type=command¶m=udevice&idx=' .. idx ..
'&nvalue=' .. nValue ..
'&svalue=' .. sValue
dz.openURL(url)
end
if dz.data.lastExecutionTime < ( dz.time.dDate - 5 ) then
pushToInfluxdb( item.idx, 0, item.rawData )
dz.data.lastExecutionTime = dz.time.dDate
else
dz.log('Too soon after last update; we don\'t want an endless loop', dz.LOG_DEBUG)
end
end
}