Unit of measurement for a template sensor

So I have speedtest giving me a download speed, but I wanted it to round to 0 decimal points so it displays without wrapping in the example below but the template version is not displaying a unit of measurement.

The guage is the speedtest download speed.
The sensor card is the rounded version.

I have put “unit of measurement” everywhere I can think but still just displays 30.

Code for template:

  - platform: template
    sensors:
      speedtest_download_rounded:
        value_template: "{{ states('sensor.speedtest_download') | float | round(0) }}"
        unit_of_measurement: 'Mbit/s'  

Code for sensor card:

    
    - type: horizontal-stack
      cards:

          - type: sensor
            name: Download
            unit_of_measurement: 'Mbit/s'
            entity: sensor.speedtest_download_rounded
            severity:
              red: 10
              yellow: 18
              green: 25

Display of card:
image

Display of guage showing Mbits/S
image

All I want is to be able to see 30 Mbit/s in the sensor card

Try using this as the value template:

"{{ states('sensor.speedtest_download') | float | round(0) }} Mbit/s"

Thanks, that works but I do not get the smaller, lighter font as per my other cards.

I am sure there must be a way to add a unit of measurement to entity, tried typing it in on the states screen but it doesnt stay.

image

Looks like I needed this:

  - platform: template
    sensors:
      speedtest_download_rounded:
        unit_of_measurement: 'Mbit/s'
        value_template: "{{ states('sensor.speedtest_download') | float | round(0) }}"

with unit of measurement above value

works now:

That’s… weird. It ultimately shouldn’t matter. I was surprised that your original sensor didn’t display the unit of measurement.

Glad it’s working though.

Yeah didnt think it should have made any difference. Might have just been the multiple restarts, but will keep this format going forward to be safe.