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.

Understanding timed scripting
#2
First script should be split into one event and one scheduled. Event should handle levels and PIR lock depending on received value (true/false). Scheduled script should just send false if event script control object has been on for 1 hour. You can use these examples for auto-off functionality: http://forum.logicmachine.net/showthread.php?tid=43

Second script will always work when 3/5/8 is on. Shouldn't the script write false to 3/5/8 in the end? Also, your if sequence is somewhat incorrect, as with delta increasing more ifs will be triggered and unwanted telegrams will be sent. You need to reverse it and use elseif:
Code:
-- group address or name
trigger = '3/5/8'
control = '1/1/50'
status = '3/5/9'
-- find required object
obj = grp.find(trigger)

-- object exists and current state is "on"
if obj and obj.data then
  -- delta is in seconds
  delta = os.time() - obj.updatetime

  if delta >= 30 * 60 then
    value = 0

    grp.write(status, false, dt.bool)
    grp.write(trigger, false, dt.bool)
  elseif delta >= 24 * 60 then
    value = 4
  elseif delta >= 18 * 60 then
    value = 10
  elseif delta >= 12 * 60 then
    value = 16
  elseif delta >= 6 * 60 then
    value = 22
  else
    value = 28

    -- send status update only when status state is off
    statvalue = grp.getvalue('status')
    if not statvalue then
      grp.write(status, true, dt.bool)
    end
  end

  grp.write(control, value, dt.scale)  
end
Reply


Messages In This Thread
Understanding timed scripting - by FatMax - 19.03.2016, 10:13
RE: Understanding timed scripting - by admin - 21.03.2016, 07:17

Forum Jump: