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.

Central statuses
#1
How prepare calculating of central statuses on Logic Machine by event-script and tags? E.g. "1Floor status", "Kitchen status" ...
Reply
#2
Here are 2 functions for getting OR / AND values for binary objects with the same tag. You can then use the result to write out the status.

Code:
function tag_and(tag)
  local objects, result

  result = true
  objects = grp.tag(tag)

  for _, object in ipairs(objects) do
    result = result and object.data
  end

  return result
end

function tag_or(tag)
  local objects, result

  result = false
  objects = grp.tag(tag)

  for _, object in ipairs(objects) do
    result = result or object.data
  end

  return result
end
Reply
#3
(16.02.2016, 11:22)admin Wrote: Here are 2 functions for getting OR / AND values for binary objects with the same tag. You can then use the result to write out the status.

Code:
function tag_and(tag)
 local objects, result

 result = true
 objects = grp.tag(tag)

 for _, object in ipairs(objects) do
   result = result and object.data
 end

 return result
end

function tag_or(tag)
 local objects, result

 result = false
 objects = grp.tag(tag)

 for _, object in ipairs(objects) do
   result = result or object.data
 end

 return result
end

ThanksWink
Reply
#4
Is there any solution to prevent executing this function on every tag change?

When there is 5 - 10 statuses, there is no problem, but if there is 100 or 200 statuses of whole house, script has to execute 100 time which can slow down LM...
Reply
#5
(18.02.2016, 08:21)Pawel Wrote: Is there any solution to prevent executing this function on every tag change?

When there is 5 - 10 statuses, there is no problem, but if there is 100 or 200 statuses of whole house, script has to execute 100 time which can  slow down LM...

Before doing a function you can check if the status of this lamp is the same that the central status.

Code:
tag="kitchen"
if status1~=central then
tag_or(tag)
end
Reply


Forum Jump: