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.

Resident script pump circulation
#6
1. Add tag valve to your valve objects. Create an event script that is mapped to valve tag:
Code:
-- get OR'ed value of all tagged objects
value = false
objects = grp.tag('valve')
for _, object in ipairs(objects) do
  value = value or object.value
end

if value then
  -- save pump timer if timer has not been started yet
  time = storage.get('pump_on_time', 0)
  if time == 0 then
    storage.set('pump_on_time', os.time())
  end
else
  -- turn pump off
  storage.set('pump_on_time', 0)
  grp.checkwrite('pump', false)
end

2. Create either a resident script with large sleep time or a scheduled script that runs every minute:
Code:
-- turn pump on when time delta >= 5 minutes
time = storage.get('pump_on_time', 0)
if time > 0 then
  delta = os.time() - time

  if delta >= 5 * 60 then
    grp.checkwrite('pump', true)
  end
else
  grp.checkwrite('pump', false)
end

In both scripts replace pump with pump object name or group address.
Reply


Messages In This Thread
RE: Resident script pump circulation - by admin - 08.03.2018, 12:46

Forum Jump: