Logic Machine Forum
Event script: last group address tag - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Event script: last group address tag (/showthread.php?tid=2640)



Event script: last group address tag - Domoticatorino - 13.05.2020

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.


RE: Event script: last group address tag - admin - 13.05.2020

event.dst contains the group address that triggered the event


RE: Event script: last group address tag - Domoticatorino - 14.05.2020

(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)



RE: Event script: last group address tag - admin - 14.05.2020

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



RE: Event script: last group address tag - Domoticatorino - 15.05.2020

(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.



RE: Event script: last group address tag - Daniel - 15.05.2020

'se'- script. If event is not created by script then write this object value to tags.


RE: Event script: last group address tag - Domoticatorino - 16.05.2020

Thank you very much.