Logic Machine Forum
Add scheduler with a single click ? - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.logicmachine.net/forumdisplay.php?fid=2)
+--- Thread: Add scheduler with a single click ? (/showthread.php?tid=5513)



Add scheduler with a single click ? - Simuzer - 14.07.2024

Hi all,

i can try adding scheduler into LM.

This example, there are 3 lamps and 3 sensors. And they a lot of my project in 3 LM. (over 500 objects for scheduler)



   

how to add schedule each lamp and sensor? One by one ?


   


Or, Is there a shortcut for scheduler to the object on the page?

Can we automatically add scheduler with a single click, as seen in the picture below?

   

thanks all you.


RE: Add scheduler with a single click ? - admin - 15.07.2024

Can be done via a script. This example creates a scheduler for objects from 0/0/1 to 0/0/5.
Code:
webrequest = require('webrequest')

for i = 1, 5 do
  address = '0/0/' .. i

  data = {
    object = buslib.encodega(address),
    active = 'on',
    controlobject = 0,
    name = 'Scheduler ' .. address,
    start_day = 1,
    start_month = 1,
    end_day = 31,
    end_month = 12,
  }

  webrequest('schedulers', 'save', { data = data })
end



RE: Add scheduler with a single click ? - Simuzer - 16.07.2024

Unfortunately this is not suitable for me. Because the addresses do not go in a certain order and the names must also be meaningful. But if it was a visual addition then things would be great. I hope such an option will be added in the future.


RE: Add scheduler with a single click ? - admin - 16.07.2024

The script can modified to create schedulers for a given tag and use object names as scheduler names. Alternatively a table with group address -> scheduler name mapping can be used to quickly create multiple schedulers.


RE: Add scheduler with a single click ? - Simuzer - 17.07.2024

(15.07.2024, 06:39)admin Wrote: Can be done via a script. This example creates a scheduler for objects from 0/0/1 to 0/0/5.
Code:
webrequest = require('webrequest')

for i = 1, 5 do
  address = '0/0/' .. i

  data = {
    object = buslib.encodega(address),
    active = 'on',
    controlobject = 0,
    name = 'Scheduler ' .. address,
    start_day = 1,
    start_month = 1,
    end_day = 31,
    end_month = 12,
  }

  webrequest('schedulers', 'save', { data = data })
end

how can i add object name for objects from 32/2/1 to 32/2/252.

I don't understand how to use the code below in the code above.

Code:
name = grp.find(event.dst).name

i want to use scheduler names as the name of the scheduler.

   


i added it manually.

   


RE: Add scheduler with a single click ? - Daniel - 17.07.2024

Code:
webrequest = require('webrequest')

for i = 1, 252 do
  address = '32/2/' .. i

  data = {
    object = buslib.encodega(address),
    active = 'on',
    controlobject = 0,
    name = grp.find(address).name,
    start_day = 1,
    start_month = 1,
    end_day = 31,
    end_month = 12,
  }

  webrequest('schedulers', 'save', { data = data })
end