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.

Event script: last group address tag
#1
Dear all,
I am doing an event script by tag assigned to 1 byte object.

Hence

object = grp.tag('cdz mode') -- cdc mode is tag of 1 byte group address

with Log(object) I can see the tables of all group address with 'cdz mode'.

I would like to take in consideration only the last group address with 'cdc mode' tag which start the script event.

How can do that?

Thanks.
Reply
#2
event.dst contains the group address that triggered the event
Reply
#3
(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)
Reply
#4
If I understand you correctly you need something like this. It will write the received event value to all objects with mytag. The write part will not run if the value was sent by an event script to prevent loops.
Code:
if event.sender ~= 'se' then
  value = event.getvalue()
  grp.tag('mytag'):write(value)
end
Reply
#5
(14.05.2020, 11:58)admin Wrote: If I understand you correctly you need something like this. It will write the received event value to all objects with mytag. The write part will not run if the value was sent by an event script to prevent loops.
Code:
if event.sender ~= 'se' then
  value = event.getvalue()
  grp.tag('mytag'):write(value)
end

Great thank you very much.
Could you explai me the meaning of event.sender ~= 'se'. What does it mean 'se'?
Thanks.
Reply
#6
'se'- script. If event is not created by script then write this object value to tags.
------------------------------
Ctrl+F5
Reply
#7
Thank you very much.
Reply


Forum Jump: