Inconsistent display of mqtt sensor

Hello,
i have some sensors coming over mqtt for speedtest results. As you can imagine, some of them are speeds (Mbit/s) and some are times (ping, in ms).
It seems to me there is something strange in pings display.
This is the config of a couple of example sensors:

    #speedtest
    - name: "Speedtest Ping"
      unique_id: "speedtest_ping"
      icon: mdi:speedometer
      device_class: "duration"
      state_class: "measurement"
      state_topic: "sensors/data/speedtest"
      unit_of_measurement: "ms"
      suggested_display_precision: 3
      value_template: "{{ value_json.ping.latency }}"
    - name: "Speedtest Download"
      unique_id: "speedtest_download"
      icon: mdi:speedometer
      device_class: "data_rate"
      state_class: "measurement"
      state_topic: "sensors/data/speedtest"
      unit_of_measurement: "Mbit/s"
      suggested_display_precision: 1
      value_template: "{{ value_json.download.bandwidth * 8 / 1000000 }}"

This is what i see in lovelace, and already there is something wrong: why “ms” is not shown if “Mbit/s” is shown?

image

and, more than this, there is something MORE strange to me (for the first image i would have said that the number coming from MQTT was 0,002. It is not)

as you can see, ha knows the right value (for example, the last is 2.568), but so why is it showing that 0.002 without unit in the top right part of the box?

Can it depend on the fact that the “duration” device_class should be expressed only as:
image

but as far as i know there is not a deny in defining different unit of measurement…
ideas?
thanks

As ms is not a valid unit of measurement for a duration, I guess it’s converted to seconds?

well if it’s not valid i assume HA is not understanding it :slight_smile:
and this would not explain the graph scale, is it?

Fact is, 2ms = 0.002s
A coincidence? :thinking:

1 Like