14.05.2020, 11:23
(13.05.2020, 16:15)admin Wrote: event.dst contains the group address that triggered the event
Hi admin,
thank you for your help. What is wrong with this script below?. Addresses have same tag and I would like that the last one which writes update the other one in the same way. Obviously it generates a loop and I would avoid with the script below. It does not work.
What do you suggest please?
Code:
value = grp.find(event.dst).value
last_thermostat = grp.find(event.dst).address
if last_thermostat == '0/0/1' then
tpid = storage.get('PID:' .. _SCRIPTNAME)
if tpid ~= nil then
os.kill(tpid, signal.SIGKILL)
end
pid = os.getpid()
storage.set('PID:' .. _SCRIPTNAME, pid)
grp.write('0/0/2', value)
else
tpid = storage.get('PID:' .. _SCRIPTNAME)
if tpid ~= nil then
os.kill(tpid, signal.SIGKILL)
end
pid = os.getpid()
storage.set('PID:' .. _SCRIPTNAME, pid)
grp.write('0/0/1', value)
end
storage.delete('PID:' .. _SCRIPTNAME)