Logic Machine Forum
Scheduler Status - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Scheduler Status (/showthread.php?tid=3386)



Scheduler Status - Zandkever - 24.05.2021

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?


RE: Scheduler Status - admin - 25.05.2021

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)



RE: Scheduler Status - Zandkever - 25.05.2021

Thanks for the quick response, I got it working.


RE: Scheduler Status - davidchispas - 23.06.2022

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)



RE: Scheduler Status - admin - 24.06.2022

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



RE: Scheduler Status - BartR - 25.06.2023

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.


RE: Scheduler Status - admin - 26.06.2023

See this: https://forum.logicmachine.net/showthread.php?tid=4459&pid=28742#pid28742


RE: Scheduler Status - BartR - 26.06.2023

(26.06.2023, 08:36)admin Wrote: See this: https://forum.logicmachine.net/showthread.php?tid=4459&pid=28742#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.