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.

Alarm missing grp update
#1
Hi 

I am looking for a solution that i need an alarm if a group address is not updated within a certain time. 
Received a script from another user that was working in beginning. But when i tried to change the time down it dont seem to work anymore. 
Any thoughts? Original script below

Code:
heartbeat_time = 60 -- Minutes
heartbeat_device_object = '32/1/2' -- Change address to your heartbeat device
heartbeat_alarm_object = '32/1/3' -- Change address to a alarm address


hb_d_obj = grp.find(heartbeat_device_object)
hb_a_obj = grp.find(heartbeat_alarm_object)

if hb_d_obj then
  local delta = os.time() - hb_d_obj.updatetime
  if delta >= heartbeat_time * 60 and hb_a_obj.value == false then
    grp.write(heartbeat_alarm_object, true)
  elseif delta < heartbeat_time * 60 and hb_a_obj.value == true then
    grp.write(heartbeat_alarm_object, false)
  end
end
Reply
#2
Scripts looks ok. How is it set up, as a scheduled script which runs every minute?

It can be written a bit shorter like this, logs might help you to find out why it's not working.
Code:
heartbeat_time = 60 -- Minutes
heartbeat_device_object = '32/1/1' -- Change address to your heartbeat device
heartbeat_alarm_object = '32/1/2' -- Change address to a alarm address

obj = grp.find(heartbeat_device_object)

if obj then
  delta = os.time() - obj.updatetime
  alarm = delta >= heartbeat_time * 60
  log(delta, alarm)
  grp.checkwrite(heartbeat_alarm_object, alarm)
end
Reply
#3
(11.09.2020, 08:40)admin Wrote: Scripts looks ok. How is it set up, as a scheduled script which runs every minute?

It can be written a bit shorter like this, logs might help you to find out why it's not working.
Code:
heartbeat_time = 60 -- Minutes
heartbeat_device_object = '32/1/1' -- Change address to your heartbeat device
heartbeat_alarm_object = '32/1/2' -- Change address to a alarm address

obj = grp.find(heartbeat_device_object)

if obj then
  delta = os.time() - obj.updatetime
  alarm = delta >= heartbeat_time * 60
  log(delta, alarm)
  grp.checkwrite(heartbeat_alarm_object, alarm)
end
Was first put in event based. My mistake. Now put into scheduled, but lowest number under minutes seems to be in scheduled script */2, */1 gives error.

It change into alarm. But booleon values written into the heartbeat device dont seem to change the alarm. It just continues to say "True".
Device writes cyclical every 30 sec. And i changed the script down to 1 minutes and the multiplier down to * 1.
Maybe this is to tight.
Log shows this.:
   
Reply
#4
You can't run scheduled script more often than once per minute. For shorter intervals use a resident script.
Reply


Forum Jump: