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.

Scheduled script
#1
Hi, I need the script triggered by one event first to check whether it is 8am to 8pm, whether it is Monday to Friday and eventually April to October. Can you please advise me? Thanks
Reply
#2
Can you describe the task that you have?

You can get current date/time as a Lua table like this and write your checks accordingly:
Code:
dt = os.date('*t')
Reply
#3
Hi admin, thanks for your reply. My task is to run blinds from Monday to Friday and from May to October. The blinds are to run at 8am and pull out at 8pm. At the same time, I need the script to respond to changes in the wind sensor and rain sensor addresses. This means that during the day it will rain the blinds pulls the control script on the rain, but after the end of the rain, the script will again respond.
Reply
#4
You can use the scheduler for the first part: open from 8am to 8pm, May->October
For the other, you can do a script base on the rain/wind event, probably using a tag, that will give/remove control of the blind.
Reply
#5
I know this, but I need to run a scheduled script with all the conditions (hour, day, month) after the rain,
Reply
#6
no need.
you have the scheduler link to an object:  objA
then you have a script which control the curtain: sc1 link to objA
And a second one for the weather computation : sc2 attach to a tag: weatherSensor

Your rain sensor object, wind, ... any weather related object is tagged as weatherSensor

So, you'll have something like this:
sc1 will be called with the scheduler.
If it's raining, sc2 will be called and will disable sc1. once the rain is gone, sc2 will be called again to reactivate sc1 and run it.
In sc1, you just need to verify if blind should be open or close regarding the value of objA.

it will give code something like this:

script1
Code:
cmdblinds = grp.getvalue('objA')
if cmdblinds then
-- open blinds
else
-- close blinds
end
script2
Code:
rain = grp.getvalue('rainStatus')
wind = grp.getvalue('windStatus')
--...

if rain or wind or ... then
--disable ctl
script.disable('script1')
-- close blinds?
else
--enable script
status = script.status('script1')
if not status then
   script.enable('script1')
   grp.write('objA',grp.getvalue('objA')) -- update the object to start script 1
end
end

I'm sure it can be optimized, but this will do the trick.
Reply
#7
to MLAUDREN, thanks for your help and inspiration...
Reply
#8
Line 13 of script 2 must be script.enable ..
Reply
#9
Correct Erwin! wrong copy/past...
I've updated the script.
Reply


Forum Jump: