10.09.2020, 20:49
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
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