In this case, nothing. It’s a left over from the piece of code you copied it from. It was useful there, but not used by you here.
I’d make a couple more points, so that you don’t unnecessarily duplicate effort:
All your reports can be generated (separately) by one handler if you add a parameter such as `&report=dsc’ to the request. The handler has to parse this parameter and then dispatch the appropriate function to generate the output. The header and style information would be shared between reports.
local function hue_rep()
-- whatever needed to consruct report HTML
return report_html
end
local function dsc_rep()
-- whatever for this report, etc...
end
function HTTP_reports (_, params)
local reports = {hue = hue_rep, dsc = dsc_rep, lasttrip = last_rep, lights = light_rep}
local fct = reports[params.report] or dsc_rep -- dsc is default if not specified
return fct, "text/html"
end
Your loop which builds each line of the report would be much clearer (and more efficient) if written like this:
local line = [[
<tr class=custom>
<td class=custom>%s</td>
<td class=custom>%s</td>
</tr>
]]
for n,d in ipairs(tt) do
html[#html+1] = line: format (luup.devices[d.devnum].description, d.ltime)
end