05.09.2016, 11:06
(This post was last modified: 05.09.2016, 15:20 by Erwin van der Zwart.)
Hi Jetsetter,
With this script you can enable/disable a scheduler:
But why don't you create a logic block with script, create a dummy object for scheduler (linked to input 1 of logic), your enable/disable object (linked to input 2 of logic)
and your switching object (linked to output of logic)
This way you can control the output of the scheduler without writing to DB...
BR,
Erwin van der Zwart
With this script you can enable/disable a scheduler:
Code:
-- Get new value for scheduler
value = event.getvalue()
-- Set scheduler name
scheduler_name = 'Scheduler 1'
-- Get schedulers from DB
query = 'SELECT * FROM schedulers'
for _, scheduler in ipairs(db:getall(query)) do
if scheduler.name == scheduler_name then
if value == true then
db:update('schedulers', { active = 1 }, { id = scheduler.id })
log('Scheduler ' .. scheduler_name .. ' is enabled')
else
db:update('schedulers', { active = 0 }, { id = scheduler.id })
log('Scheduler ' .. scheduler_name .. ' is disabled')
end
end
end
-- Call cleanup of old schedulers
clearschedulers()
But why don't you create a logic block with script, create a dummy object for scheduler (linked to input 1 of logic), your enable/disable object (linked to input 2 of logic)
and your switching object (linked to output of logic)
This way you can control the output of the scheduler without writing to DB...
BR,
Erwin van der Zwart