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
#6
is it also possible to adjust the time via DB queries?
In the Netherlands we can use variable hourly rates for electricity. Each hour of the day has a different rate. I'm working on a script that selects the best charging time based on when we need EV again. I just can't manage to send that time to a schedule.
Reply
#7
See this: https://forum.logicmachine.net/showthrea...2#pid28742
Reply
#8
(26.06.2023, 08:36)admin Wrote: See this: https://forum.logicmachine.net/showthrea...2#pid28742

Thanks!

Maybe one more tip.
I have downloaded the config of my (HomeLynk). In the folder storage/db there is a file current.db. Here is the entire database of your homelynk.
Using a tool such as DB browser for SQLite you can easily search the entire DB and adjust advanced parts via your scripts.
Reply


Forum Jump: