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
#1
Is there a possibility in new firmware to change the Schedulers from script? This will be very helpful especially in the hotels.
Reply
#2
in upcoming release this will not be possible, but for the next versions we have planned this feature. Thanks for suggestion.
Reply
#3
Hi,

Is there an ETA when this will be available?

Thanks,


Roger
Reply
#4
Which features exactly do you need?
Reply
#5
Hi,

I know that we can add\change\remove either scheduled scripts or schedules via the database. But it would be much simpler when there are a functions to do this.

Thanks,

Roger
Reply
#6
Hi,

I need at least to be able to enable or disable an existing scheduler based on some logic from a script, so can someone explain how can I do this at least via the database?

It would be also very useful to be able to modify an existing event of a scheduler (time/date/value) as well as be able to remove an event completely or add a new one.


tnx in adv
BR
Reply
#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
#8
If running RC firmware you must call clearschedulers() after making any changes, otherwise all scheduler events until the end of the day will still run even when the scheduler is disabled.

Simplified Erwin's example:
Code:
name = 'Scheduler 1'
active = event.getvalue()

db:update('schedulers', { active = toboolean(active) }, { name = name })
clearschedulers()
Reply
#9
(05.09.2016, 11:06)Erwin van der Zwart Wrote: 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... 

Thank you very much Erwin.
You mean like an AND gate? It is a nice idea, the only problem with this way is that the end user will not know if the scheduler is actually active or not by looking at it at the schedulers page, he should reside in the dummy object I/O at the visualisation...
Any way, I will try both ways, I hope the final release will have some easier way to manipulate the schedulers.

Thank you all.
Reply
#10
Hi,

I'm trying something similar

I'm able to add an entry in a scheduler, but nothing happen at the specified time.
If I add it manually using the GUI, it's ok.

clearschedulers() function return an error : `attempt to call global 'clearSchedulers' (a nil value)`

Any idea?
Reply
#11
Hi,

You probably use FW that don't have the function yet..

What HW/FW do you use? (probably HL/SL?)

BR,

Erwin
Reply
#12
Looks like this function is available only to GUI, you can add it to common functions to use in your scripts.

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
Reply
#13
Yep, I have a hL.

FW 1.5.1

I had another tips :

add this at the begenning of the script.

Code:
ngx = {}
json= {}
dofile("/lib/genohm-scada/web/lib.lua")

Which one is prefered?
Reply
#14
Hi,

Has there been any progress on this in the latest firmware?

Thanks,


Roger
Reply
#15
I was able to change schedulers and scheduler's event from a script.
So I think all can be done if you know how to do it.

If admin is agree, I'll post a sample here.
Reply
#16
You can change schedulers via database queries. This is not recommended since database schema might change between firmware releases, but for now there's no other way.
Reply
#17
(04.01.2017, 13:53)admin Wrote: You can change schedulers via database queries. This is not recommended since database schema might change between firmware releases, but for now there's no other way.

Hi, any news on when we will be able to modify schedulers without DB queries? Is it going to be included in the upcoming release?

tnx
Reply
#18
I'm interested too
KNX Advanced Partner + Tutor
Reply
#19
Hi, is there any change to for RC1?

thx

Roger
Reply
#20
Not yet, can you explain your use case for this in more detail?
Reply


Forum Jump: