04.11.2019, 07:49
(This post was last modified: 04.11.2019, 07:49 by christian.troen@haaland.no.)
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.
Summing Values
|
04.11.2019, 07:49
(This post was last modified: 04.11.2019, 07:49 by christian.troen@haaland.no.)
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.
04.11.2019, 08:23
Tag all objects you want to sum and you can use this
Code: 12345678910111213141516 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
04.11.2019, 09:30
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?
04.11.2019, 10:41
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: 12345678910111213141516171819 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)
------------------------------
Ctrl+F5
04.11.2019, 12:03
Thank you! Worked very well
![]()
04.11.2019, 14:03
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.
04.11.2019, 14:26
Of course a Boolean is not a number. For binary use such script.
Code: 123456789101112131415161718192021 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
04.11.2019, 23:31
Daniel, since you are on a roll
![]() 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.
05.11.2019, 08:26
To be honest I didn't even look what the values are, it was a number
![]() What exact logic are you looking at?
------------------------------
Ctrl+F5 |
« Next Oldest | Next Newest »
|