LogicMachine Forum
Scheduler control via script - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Scheduler control via script (/showthread.php?tid=6242)



Scheduler control via script - iridium - 08.01.2026

Hello,

I need to be able to delete events from a scheduler using a script.

I'd like to be able to delete a specific event and also delete all of them.
To create them, I'm using the script I found on the forum:


webrequest = require('webrequest')

data = {
  value = '0', -- value to send
  scheduler = 8, -- parent scheduler ID
  name = 'new event',
  active = 'on', -- 'on' or 'off'
  type = '', -- '' (run at specific time), 'sunrise' or 'sunset'
  start_hour = 13, -- only for run at specific time
  start_min = 0, -- only for run at specific time
  offset_hour = -1, -- only for 'sunrise' or 'sunset'
  offset_min = 30, -- only for 'sunrise' or 'sunset'
  year = 0, -- 0 = all years, specific year otherwise
  months = '111111111111', -- Jan to Dec, 1 = on, 0 = off
  daysofmonth = '1111111111111111111111111111111', -- 1..31, 1 = on, 0 = off
  daysofweek = '1111111', -- Monday to Sunday, 1 = on, 0 = off
  dayweeknrs = '111111', -- week 1 to 5 in month, 6th value = Last week of the month, 1 = on, 0 = off
  holidays = '', -- '' (don't care), 'y' (run on holidays), 'n' (don't run on holidays)
}

res, err = webrequest('schedulers', 'events-save', { data = data })
log(res, err)

Thanks!!


RE: Scheduler control via script - admin - 08.01.2026

To delete events use 'events-delete' and data = { id = EVENT_ID } respectively.

Use this code to get all events for a particular scheduler:
Code:
scheduler_id = 123
ids = db:getlist('SELECT id FROM scheduler_events WHERE scheduler=?', scheduler_id)
for _, id in ipairs(ids) do
  log(id)
end