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.

Swimming pool Scheduled script
#1
Hello everyone, 
hope you're doing well. 
If I have a swimming pool with 2 motors (M1, M2) and I need to make the following: 
-Weekly only 1 motor works. (ex: Week 1 --> M1, week 2 -->M2, etc)
-In Summer: ON for 1 hour,  off for 1 hour then repeat till the end of the day. 
-In winter: ON for 1 hour,  off for 2 hours then repeat till the end of the day. 

I already make it with the schedulers but I couldn't make it with scripting!
any ideas, please? 
Thanks for your time.
Reply
#2
How is winter/summer mode set? Via an object or calculated based on current date?
Reply
#3
(11.10.2022, 13:01)admin Wrote: How is winter/summer mode set? Via an object or calculated based on current date?

Thanks for your reply,It will be based on the current date.
Reply
#4
So which months should be included in the summer mode? June-August or something else?
Reply
#5
(11.10.2022, 13:19)admin Wrote: So which months should be included in the summer mode? June-August or something else?
yes from June to September.
Reply
#6
Create a scheduled script that runs once every hour:
Code:
addr1 = '1/1/1'
addr2 = '1/1/2'

week = tonumber(os.date('%W'))
hour = tonumber(os.date('%H'))
month = tonumber(os.date('%m'))

-- swap outputs on even weeks
if week % 2 == 0 then
  addr2, addr1 = addr1, addr2
end

-- summer mode (June 1st to August 31st)
if 6 <= month and month <= 8 then
  on = hour % 2 == 0
else
  on = hour % 3 == 0
end

grp.write(addr1, on)
grp.write(addr2, false)
Reply
#7
(13.10.2022, 06:48)admin Wrote: Create a scheduled script that runs once every hour:
Code:
addr1 = '1/1/1'
addr2 = '1/1/2'

week = tonumber(os.date('%W'))
hour = tonumber(os.date('%H'))
month = tonumber(os.date('%m'))

-- swap outputs on even weeks
if week % 2 == 0 then
  addr2, addr1 = addr1, addr2
end

-- summer mode (June 1st to August 31st)
if 6 <= month and month <= 8 then
  on = hour % 2 == 0
else
  on = hour % 3 == 0
end

grp.write(addr1, on)
grp.write(addr2, false)
Thanks for your reply, It's working well, but I need to study it!
Thanks again for your support.
Reply


Forum Jump: