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.

last active groupadress
#1
I hope someone can help me.

i want to make a script to automatic activated my alarm.

so i need to know what group address was last changed.

i want to check all group adresses between
14/0/25 and 14/0/68 *but there are some group adresses they dont excist.
and if group adress 14/0/49 or 14/0/52 was last who changed, i want to sent a 'true' command to 14/2/1

i hope it doenst matter if some of them are still active of or not, i just want to know who was the last one who changed of state.
Reply
#2
Use an event script with a tag and check event.dst
Reply
#3
Hi admin,

is it also possible to run a script on scheduled en just check at that moment?
to check what adres did chanced last?
I only want run the script on 11pm.
so i think it is better to just check that time.
Reply
#4
Use this:
Code:
tagobjs = grp.tag('tag_name')
maxtime = 0

for _, tagobj in ipairs(tagobjs) do
  updtime = tonumber(tagobj.updatetime) or 0
  if updtime > maxtime then
    obj = tagobj
    maxtime = updtime
  end
end

log(obj)
Reply
#5
Thanks admin, it looks like it is working.

Just curious to understand better scripts.

Why is this part of script need for?
Code:
  if updtime > maxtime then
changing the maxtime, doesnt look do anyting.
and why doesnt work
Code:
log(tagobj)
for me it looks like its the same as 'log(obj)' , but it isn't?
Reply
#6
maxtime stores the maximum update time, it is changed when an object with a larger update time is found. Another option would be to sort the tagged object table by the updatetime field and use the first element of the table.
tagobj is a local variable and it's only visible inside the for loop.
Reply


Forum Jump: