could somebody please help me how I need to setup a template sensor to display my up- and download speeds in KB/s or when appropriate in MB/s? Currently the sensor reports the rates in bytes which is not very useful to me. I guess I need to convert the bytes to KB or MB and the also change the unit of measurement when a threshold is reached and this exercise currently exceeds my knowledge.

For what its worth I am using the fritzbox Netmonitor sensor which reports the current speeds in bytes/s.

Hello, I am a new user of HA I also have a problem with conversion to Mb / s
where exactly should I put this line to work? {{states.sensor.bytes_sent | filesizeformat ()}} / s

I guess you need to realize what you are cutting off, in your case 1048576 is only stripped.
You probably want to have your whole calculation stripped of like this example:

states(‘sensor.frlmx_b_sent’) | float
(putting spaces in makes it easier to read) takes the value (state) of sensor.frlmx_b_sent and casts it to float (makes a text string into a number value with decimals) This is the first calculation

1073741824 | round(2)
Takes 1073741824 and casts it to round(2) 2 decimal places, but it has no decimal places so it stays as it is - second calculation

float_value / rounded_value
(\ is way down the pecking order) just divides float_value by 1073741824 third calculation

So you need to add brackets to shift the priorities, so that you | round(2) last of all
So : -
“{{ (states(‘sensor.frlmx_b_sent’) | float / 1073741824) | round(2) }}”
This moves the second calculation to “divide by 1073741824”

Each of these are ‘operations’ not strictly ‘calculations’ as changing something from text to a number is a grey area - calculation wise

Okay,
You know that these are decimal representaions of binary numbers ?
1,2,4,8,16,32,64,128,256,512,1024 etc (shortcut 2^n)
So a Kilo (1000) bit is 1024
So strictly speaking k to M should be divided by 1024
I have no Idea where you got 1073741824 from (but that was NOT the question you asked)
This is hard for some people to understand so they have ‘decimalised’ binary numbers and it is quite common to see Mb * 1000 = kb (thats Mb = kb / 1000)
If you don’t like the answer - change the divisor