I am not a expert in DzVents, just use basic LUA myself, but shouldn't this it bit :
Code: Select all
if not item.isHTTPResponse then
triggerJSON(usageDevice.idx, "year")
elseif item.ok then -- statusCode == 2xx
yearTotal.update(0,calculateYearTotal(item.json.result))
else
logWrite("Could not get (good) data from domoticz. Error (" .. (item.statusCode or 999) .. ")" ,dz.LOG_ERROR)
logWrite(item.data)
end
look like this:?
Code: Select all
if item.isTimer then
triggerJSON(usageDevice.idx, "year")
elseif item.ok then -- statusCode == 2xx
yearTotal.update(0,calculateYearTotal(item.json.result))
else
logWrite("Could not get (good) data from domoticz. Error (" .. (item.statusCode or 999) .. ")" ,dz.LOG_ERROR)
logWrite(item.data)
end
To avoid multiple triggers and log errors when they occur?
EDIT:Is the u_max field always there in each record? I don't think i have any Energy device that contains that field so can't check.
When it isn't always present you could try changing these lines to avoid any hard LUA NIL errors to:
Code: Select all
logWrite(rt.d .. " ==>> " .. (rt.u_max or 0))
yearTotal = yearTotal + (rt.u_max or 0)