hello
I want to create a script that will trigger outputs if the current date and time matches the date and time in an array, array size will be 365*7
I have six-times columns for each day *365 days
for each column of the six columns a different output will be triggered.
what is the most efficient way to do this and which kind of scripts should I use?
The question is where the schedule data comes from and if it should be editable by the end user. If the schedule is fixed then you can simply create a table with date/time and use a scheduled script that runs every minute to check if date/time matches.
(08.11.2021, 09:45)admin Wrote: The question is where the schedule data comes from and if it should be editable by the end user. If the schedule is fixed then you can simply create a table with date/time and use a scheduled script that runs every minute to check if date/time matches.
thanks, admin
its a fixed date/time table
the date/time table represents the pray time for each day of the year.
I want to control the light and AC of the masjid (mosque) eg. turn on the light before azan time by x minutes if sunset.
I hope the description is clear now, what is your suggestion admin?
regards,
(08.11.2021, 13:19)admin Wrote: I suppose there should be a formula for calculating times for each date. Might be easier to implement it instead of a fixed table.
Thanks Admin
Yeah, there is a formula, but I didn't find the accurate one, so a fixed table will be an alternate way if I failed to find the accurate formula.
Script runs every minute and checks if there's a matching date/time inside the schedule table. The schedule is defined once with all dates and times for the year. Put your actions after the "-- execute action" line. It will only be executed for matching date and time.
13.11.2021, 11:23 (This post was last modified: 16.11.2021, 09:45 by khalil.)
Hello Admin
is there a chance that the schedule script miss the table time so the execution occurs before or after the desired time?
another question, I am trying to compare real time with the table time e.g. if nowTime (>,<,=) tableTime[Y] (+-) X then do something
Edit: This is what I did, any advice admin?
Code:
12345678910111213141516171819202122232425
dtbl = os.date('*t')
date = string.format('%d/%d', dtbl.day, dtbl.month)
time = string.format('%d:%02d', dtbl.hour, dtbl.min)
timeNum = (dtbl.hour-y)*60 + (dtbl.min-x) -- current time in minutesc = 0-- to know active table time (active pray)schedtimes = schedule[ date ] or {}
for_, schedtimeinipairs(schedtimes) doc=c+1prayTimeAry = string.split(schedtime, ':')
prayNum = tonumber(prayTimeAry[1]*60) + tonumber(prayTimeAry[2])
if (prayNum - timeNum ) == 1then----edit log ("amplifier CMD")
elseifschedtime == timethenlog ('Azan CMD')
-- grp.write('1/0/37',true) elseif (timeNum - prayNum) == 6thenlog("Turn OFF System")
endend
It's very unlikely that the scheduled script will miss its execution. It would be better to use a formula and create scheduler events for the current day one per day.
Have you seen this Python script? Should be quite easy to rewrite it into Lua: http://praytimes.org/code/git/?a=viewblo...aytimes.py
(15.11.2021, 07:57)admin Wrote: It's very unlikely that the scheduled script will miss its execution. It would be better to use a formula and create scheduler events for the current day one per day.
Have you seen this Python script? Should be quite easy to rewrite it into Lua: http://praytimes.org/code/git/?a=viewblo...aytimes.py
thank you admin for your time,
I see such websites that used formula but in our region they used a table while there are several minutes different between the table and the formula (not in all days and not in all prays). So I will use the table because its the most reliable right now.