Logic Machine Forum
Create/Delete scheduler with a script - Printable Version

+- Logic Machine 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: Create/Delete scheduler with a script (/showthread.php?tid=1895)



Create/Delete scheduler with a script - MantasJ - 09.02.2019

Hello,

Is it possible to create/delete a scheduler with defined parameters (name, controlled object, events with their starting times/values...) with a script? if so, how?

Thanks in advance.


RE: Create/Delete scheduler with a script - admin - 11.02.2019

For now the only solution is to use DB queries. You can find some info here:
https://forum.logicmachine.net/showthread.php?tid=265

You will also need to call clearschedulers() after making any changes, see post #12 there for function code.


RE: Create/Delete scheduler with a script - MantasJ - 11.02.2019

Thanks for Your answer. Yes, I'm already aware of the possibility of modifiying schedulers with DB queries. In future would be very nice to see ability to create/delete schedulers from a script.


RE: Create/Delete scheduler with a script - ralwet - 01.08.2019

Hi

I'm working on a "high availability" solution. Where I do have two spaceLynks (primary and secondary). When primary fails, secondary is activating his own scripts (script.categoryenable('HA_Category')) and is going to overtake the work. It works so far. The only problem is, that I cannot enable/disable schedulers by scripting.

My only Solution so far: Manualy deactivate/activate the schedulers on the UI => It's not a big deal because, it has only to be done when primary fails, which hopefully never happens.

But it would be great if I could do that also by scripting, without dealing with the db. IMHO this is "dangerous" because of possible incompatiblies with future FW-Releases.

I would realy appreciate a enable/disable function for schedulers, just like there is one for scripts Smile

best regards


RE: Create/Delete scheduler with a script - Erwin van der Zwart - 01.08.2019

Hi,

FW 2.4.0 is just released and should be already or comming soon on our website.

in this version we added enabling schedulers by object.

BR,

Erwin


RE: Create/Delete scheduler with a script - ralwet - 01.08.2019

This sounds very interesting! I just installed FW 2.4.0 Smile

Do you have a quick example to do enabling/disabling in lua-script?


RE: Create/Delete scheduler with a script - Thomas - 02.08.2019

Hi
I do the same thing. I've primary and backup LM.
My code for enabling/disabling schedulers is here:
Code:
function _clearschedulers()
  local files = io.ls('/tmp')
  for _, file in ipairs(files) do
    if file:find('lm-scheduler-', 1, true) then
      os.remove('/tmp/' .. file)
    end
  end
end

function ecl_enable_all_schedulers(ai)
  -- ai must be 0 - inactivate 1 - activate
db:update('schedulers', {
    active = ai
})

_clearschedulers()
end



RE: Create/Delete scheduler with a script - equalizer - 02.08.2019

In the Schedule Events db entry what is the function of "offset_hour" "offset_min", do these advance and delay the timer? If so does it handle day rollover (if say off time is advanced beyond midnight)?


RE: Create/Delete scheduler with a script - admin - 02.08.2019

This only affects sunrise and sunset modes. Rollover cases are handled.