Skip to main content


scheduler allows adding periodic function executions.


-- @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.


function send_properties()
enapter.send_properties({version = "1.0"})

jobId = scheduler.add(10, send_properties)


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 on a single CPU core. This means that no two scheduled functions will be running in parallel.

Returns the ID of the scheduled execution. You can use it for any further executions of scheduler.remove.


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

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

Hardware diversity is welcome. Integrate any device into a unified energy network.
© 2024 Enapter
Developer toolkit