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?
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:
but as far as i know there is not a deny in defining different unit of measurement…
ideas?
thanks