Skip to main content

SchedulerHardware UCMVirtual UCM

The scheduler library allows adding periodic function executions.

scheduler.add

-- @param period number Execution interval in milliseconds
-- @param fn function Function to be executed
-- @return number Scheduled function ID
function scheduler.add(period, fn)
end

Schedules function fn for a periodic execution in period milliseconds intervals. Returns the ID of the scheduled execution. You can use it for any further executions of scheduler.remove.

Notes

Each function call is limited to 10 seconds, otherwise, the call will be terminated. It will not affect the scheduler though and the execution will continue again after the period milliseconds.

All scheduled function calls are executed sequentially. Invocation of any asynchronous function, such as system.delay(), will pause the execution of the current function, allowing other scheduled functions to run in the meantime.

Example

function send_properties()
enapter.send_properties({version = "3.0"})
end

jobId = scheduler.add(10000, send_properties)

scheduler.remove

-- @param jobId number Scheduled function ID
function scheduler.remove(jobId)
end

Removes function from Scheduler by jobId returned from scheduler.add.

All Rights Reserved © 2025 Enapter AG.