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.

Summing Values
#1
Is there an easy way for summing several values that is on the KNX-bus to one Virtual KNX-obejct? Se screenshot values that I want to sum.

Attached Files Thumbnail(s)
   
Reply
#2
Tag all objects you want to sum and you can use this

Code:
function tag_sum(tag)
  local objects, result

  result = 0
  objects = grp.tag(tag)

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

  return result
end



sum = tag_sum('TAG')
------------------------------
Ctrl+F5
Reply
#3
Thanks for the reply.
Can you please be more spesific on how i should build it to my purpose? (I am at best Poorly experienced with LULA).
If I have given the tag "Supply" to all valves, and the tag SupplySUM to the adress I want the summing value to be written to. How should I do it?
Reply
#4
You need only tag for the 'Supply' values and the you can use event script with your tag as event or resident script with interval as often you need the calculation.

Code:
function tag_sum(tag)
  local objects, result

  result = 0
  objects = grp.tag(tag)

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

  return result
end



sum = tag_sum('Supply')


grp.checkwrite('1/1/1', sum)
Change group address where you want to write it to.
------------------------------
Ctrl+F5
Reply
#5
Thank you! Worked very well Big Grin
Reply
#6
If the values are boolean, the sum does not work. Can I convert from boolean to floating point in the same script?

See screenshot. I want to display the total number of active heating-zones in in one tag.

Attached Files Thumbnail(s)
   
Reply
#7
Of course a Boolean is not a number. For binary use such script.
Code:
function tag_sum(tag)
  local objects, result

  result = 0
  objects = grp.tag(tag)

  for _, object in ipairs(objects) do
    if object.data then
    result = result + 1
    end 
  end

  return result
end



sum=tag_sum('Supply'))


grp.checkwrite('1/1/1', sum)
------------------------------
Ctrl+F5
Reply
#8
Daniel, since you are on a rollSmile
I see that the first example is air values and i guess to sum them up.
But lets say you have some supply air vav but only one central extract vav. And then want to convert the supply sum to an control value 0-100 % to control the Extract vav.
Given you know the Min/Max/Nom values of the Vav.
Been searching forum, but have not seen anything.
Reply
#9
To be honest I didn't even look what the values are, it was a number Smile
What exact logic are you looking at?
------------------------------
Ctrl+F5
Reply


Forum Jump: