This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Change shedulers from a script
#7
Hi Jetsetter,

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
Reply


Messages In This Thread
Change shedulers from a script - by buuuudzik - 08.04.2016, 08:50
RE: Change shedulers from a script - by admin - 19.07.2016, 10:03
RE: Change shedulers from a script - by Erwin van der Zwart - 05.09.2016, 11:06
RE: Change shedulers from a script - by admin - 05.09.2016, 13:21
RE: Change shedulers from a script - by admin - 15.12.2016, 10:53
RE: Change shedulers from a script - by admin - 04.01.2017, 13:53
RE: Change shedulers from a script - by admin - 25.03.2019, 07:01
RE: Change shedulers from a script - by Safar - 29.04.2019, 22:02
RE: Change shedulers from a script - by admin - 25.11.2019, 08:01
RE: Change shedulers from a script - by admin - 31.01.2021, 11:07

Forum Jump: