21.03.2016, 07:17 
		
	
	
		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:
	
	
	
	
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