How to show the right value tr-064 Fritzbox


i use the TR-064 binding on OH3 and have problems with values that returned by the binding.

How to convert this into Megabyte or Gigabyte?

from avm tr-064 documentation this are the values

Variable name Allowed values (* == default) Data type
TotalBytesReceived 0 if IGD is not used. ui4
TotalBytesSent 0 if IGD is not used. ui4

It’s already GB (or at least Giga-Octets in binary counting, for normal data this should be equivalent): Octet (computing) - Wikipedia

Ok, thanks for the clarification.

The value displayed in the router’s online counter shows other values.

i restarted the box to have new values. but i still don’t get it.

values from the box

values from openhab

any hints?

Can you try changing the display? I.e. link to an item and set the unit to B?

You also could use a simple JS transform:

(function(i) {
     return (i/(1024*1024*1024)).toFixed(2) + " GB";

and use this script (i’ve called it BytesToGB.js and put it into the transform folder) in the items metadata (state description):

Update: Even better would be to add a provile transformation. This is done at the section where you link you items to channels. So you go to the thing, select the channel you want to link (or which is already linked) and configure the transformation there

1 Like

That should not be necessary. Just changing the state description should be enough. That‘s Why we introduced UoM.

The question is why the numbers differ. Could be a conversion problem from B to GB (should be GB and not Gio. In fact that is a bug. GB was not available when I developed that binding under 2.5.x and because of that I used Gio. Should have been changed to GB prior to the release but was forgotten).

1 Like

Hi, thank you.

With metadata state descriptor it transform the value but only on the item not in openhab gui there is now shown this. but the value in sitemap looks good now.

if i use the profile js it doesnt change anything like in your screenshot it still shows th gio version.

this maybe the right values for the channel but that is definitly not the value of the online counter on the box.

Yes, i’ve added “%.2f GB” to the item’s state description. As Jan mentioned my approach should not be necessary for the binding, but for the binding i’m using in this context it is.
So i’ll hand over to Jan in order to avoid any more confusion :wink:

Ok, so the preferred way is with the metadata state descriptor, that works for me now.

Only the way its sown in the gui is NaN GB but in the logs its shown as B so all good.

But overall the value can’t be correct. i streamed in 4k yesterday evening a have transformed ~ 2,46 GB that can’t be right.

Thank you all.

11:06:14.774 [TRACE] [ing.tr064.internal.soap.SOAPConnector] - Request: <SOAP-ENV:Envelope xmlns:SOAP-ENV=“” SOAP-ENV:encodingStyle=“”>SOAP-ENV:Header/SOAP-ENV:Body<u:GetTotalBytesReceived xmlns:u=“urn:dslforum-org:service:WANCommonInterfaceConfig:1”/></SOAP-ENV:Body></SOAP-ENV:Envelope>
11:06:15.087 [TRACE] [ing.tr064.internal.soap.SOAPConnector] - Received response: <?xml version="1.0"?>
<s:Envelope xmlns:s=“” s:encodingStyle=“”>
<u:GetTotalBytesReceivedResponse xmlns:u=“urn:dslforum-org:service:WANCommonInterfaceConfig:1”>
11:06:15.087 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘WANDeviceFRITZBox6591Cablelgi_TotalBytesReceived’ changed from 3.27496134676039218902587890625 GiB to 3.28085482306778430938720703125 GiB

I guess it’s a problem with the FB. You can see the raw value received from the FB (in my case a 6591) and the conversion (/(102410241024)) is calculated and ok. So the FB reports somethinf that is not shown in the UI and the value in the UI seems to be unavailable in the TR-064 data.

Yes, that’s correct.

The value from online counter have nothing to do with these values.
But as said the values overall can’t be right if i streamed in 4k 2hours yesterday evening. That a little bit more than 2,46GB.

I have a 6591 too and hope for the latest firmware to come soon.

But thats not the problem here.

Thank you all for your help.

Solution seems to be easy: The value is ui4, so unsigned int, 4 bytes. The maximum value is 4294967295, so after around 4 GB the counter resets…

A “total” counter with a max value that resets is a little bit useless, or not? :rofl:
That is not my definition of total, but it is as it is.

Edit: Ok, i could sum it up anywhere else, if i would.

Thank for clarifying, again :wink: