I’ve got:
local taskHandle = -1
local TASK_ERROR = 2
local TASK_ERROR_PERM = -2
local TASK_SUCCESS = 4
local TASK_BUSY = 1
local MSG_CLASS = "Dummy"
local function task(text, mode)
local mode = mode or TASK_ERROR
if (mode == TASK_ERROR_PERM) then
taskHandle = luup.task(text, TASK_ERROR, MSG_CLASS, taskHandle)
else
taskHandle = luup.task(text, mode, MSG_CLASS, taskHandle)
if (mode ~= TASK_SUCCESS) then
luup.call_delay("clearTask", 30, "", false)
end
end
end
function clearTask()
luup.task("Clear", TASK_SUCCESS)
end
task("Clear", TASK_SUCCESS)
And the result in the LuaUPnP.log file is:
01 03/10/13 15:20:23.100 LuaInterface::CallFunction_Timer-5 function clearTask failed attempt to call a nil value
I’m obviously missing something, but am not sure what?
I’m not certain, but do you need to define the function clearTask before the call_delay that references it?
Yeah, sorry. Cut & paste error in the post. How it’s defined in the actual .lua file:
local taskHandle = -1
local TASK_ERROR = 2
local TASK_ERROR_PERM = -2
local TASK_SUCCESS = 4
local TASK_BUSY = 1
local MSG_CLASS = "Dummy"
function clearTask()
dbg.log("Clearing the task panel in UI5", dbg.DEBUG_VERBOSE)
luup.task("Clear", TASK_SUCCESS)
end
local function task(text, mode)
local mode = mode or TASK_ERROR
if (mode == TASK_ERROR_PERM) then
taskHandle = luup.task(text, TASK_ERROR, MSG_CLASS, taskHandle)
else
taskHandle = luup.task(text, mode, MSG_CLASS, taskHandle)
if (mode ~= TASK_SUCCESS) then
luup.call_delay("clearTask", 30, "", false)
end
end
end
… that code looks familiar 
It’ll only work in a [tt].xml[/tt] file. It won’t work in a [tt].lua[/tt] since [tt]luup.call_delay[/tt] can’t see those func defns.
[quote=“guessed, post:4, topic:174586”]… that code looks familiar 
It’ll only work in a [tt].xml[/tt] file. It won’t work in a [tt].lua[/tt] since [tt]luup.call_delay[/tt] can’t see those func defns.[/quote]
Ah, I see.
(And yes, I stole it from the Weather Underground plugin (attributed “borrow”, but still a “borrow”). If it ain’t broke… 