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.

Scheduler Status
#1
Hi,

I am implementing a UI for airco systems and use scheduler with events as a widget to schedule on/off times for the individual units. So far so good.

In the UI I would like to show additionally the status of each scheduler or for specific events in the scheduler, for the simple reason to quickly see if a schedule/event is active or not.
How do I retrieve the status of a schedule and its events to enable writing it to an object?
Reply
#2
Only via DB queries, change IDs to your scheduler/events IDs:
Code:
-- scheduler
id = 1
active = db:getone('SELECT active FROM schedulers WHERE id=?', id)
active = toboolean(active)

grp.checkupdate('1/1/1', active)

-- event
id = 2
active = db:getone('SELECT active FROM scheduler_events WHERE id=?', id)
active = toboolean(active)

grp.checkupdate('1/1/2', active)
Reply
#3
Thanks for the quick response, I got it working.
Reply
#4
Hello, how can I simplify the script following this criterion?
Code:
-- scheduler1
id = 1
active = db:getone('SELECT active FROM schedulers WHERE id=?', id)
active = toboolean(active)
grp.checkupdate('40/0/' .. id, active)

-- scheduler2
id = 2
active = db:getone('SELECT active FROM schedulers WHERE id=?', id)
active = toboolean(active)
grp.checkupdate('40/0/' .. id, active)

-- scheduler3
id = 3
active = db:getone('SELECT active FROM schedulers WHERE id=?', id)
active = toboolean(active)
grp.checkupdate('40/0/' .. id, active)

-- scheduler4
id = 4
active = db:getone('SELECT active FROM schedulers WHERE id=?', id)
active = toboolean(active)
grp.checkupdate('40/0/' .. id, active)

-- scheduler5
id = 5
active = db:getone('SELECT active FROM schedulers WHERE id=?', id)
active = toboolean(active)
grp.checkupdate('40/0/' .. id, active)
Reply
#5
Use a numeric for loop:
Code:
for id = 1, 5 do
  active = db:getone('SELECT active FROM schedulers WHERE id=?', id)
  grp.checkupdate('40/0/' .. id, toboolean(active))
end
Reply


Forum Jump: