31.03.2020, 09:49
(30.03.2020, 14:15)Daniel. Wrote: knxlib.getstats()
OK, so I got this working. I made a small resident script that tracks the busload and then writes the value to a group address. Then one can add a trend for the busload and see the bus load in % over time.
As the getstats() is not giving the load as a percentage, but rather the number of telegrams in total, I have added a paramter for the number of telegrams pr second. This is of course not an exact value, as the length of the telegrams will vary. Normally, an average telegram time is 25ms, so that should give a theoretical max of 40/s.I have used a lower value in my script.
The getstats() is also only updated every minute, so the values we get from it is only to be seen as an indication of the bus load. The trend will be able to give you a hint that there might be too high bus load, and then you will have to do a more detailed analyze of this in another tool.
As the values are somewhat uncertain when it comes to actual bus load I have not seen the value in creating seperate GA for send, receive and repeats. I have only added them all together. If one want to split it, it should be fairly easy to modify the script accordingly.
Anyways.. the code is as follows:
Code:
maxS = 15 --Highest accepted telegram rate pr second
GAtraffic = '32/1/3' --Must be set to desired GA
-------------------------------------------------------------------------
--No changes below the line
maxM = maxS*60
stats = knxlib.getstats()
if not stats then
return
end
sent = stats.tptx
received = stats.tprx
traffic = sent + received
prev = storage.get('Previous', 0)
if prev ~= 0 then
bLoad = ((traffic - prev)*100)/ maxM
if bLoad > 0 then
grp.write(GAtraffic, bLoad)
-- log(prev, traffic, bLoad)
end
end
storage.set('Previous', traffic)
There are 10 kinds of people in the world; those who can read binary and those who don't