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.

Turn off light in 4 hours
#7
Another timer example.

Task: If there is 0 sent to grp address AND it stays for 30 min at this value, switch on relay for 3 min. This is used in sauna installation to drain water after sauning is finished.

Event script, input is binary object:

Code:
value = event.getvalue() -- turn off timer and turn relay off if value then  storage.delete('timer')  grp.write('1/1/1', false) -- start timer if not already started else  timer = storage.get('timer')  if not timer then    storage.set('timer', 0)  end end

Scheduled script - run every minute:

Code:
-- check if timer is running timer = storage.get('timer') if timer then  timer = timer + 1  timer.set('timer', timer)  -- turn relay on after 30 minutes  if timer == 30 then    grp.write('1/1/1', true)  -- turn relay off after 33 minutes    elseif timer == 33 then    grp.write('1/1/1', false)  end end
Reply


Messages In This Thread
Turn off light in 4 hours - by RSV4 - 18.07.2015, 10:48
RE: Turn off light in 4 hours - by Pawel - 18.07.2015, 18:51
RE: Turn off light in 4 hours - by admin - 20.07.2015, 06:10
RE: Turn off light in 4 hours - by RSV4 - 20.07.2015, 08:01
RE: Turn off light in 4 hours - by Pawel - 20.07.2015, 09:29
RE: Turn off light in 4 hours - by admin - 21.07.2015, 08:19
RE: Turn off light in 4 hours - by edgars - 22.01.2016, 07:58

Forum Jump: