mkanet
(MKANET)
May 15, 2020, 12:50am
1
I am trying to convert bps to Mbps in a temple. However, the result state value is just “unknown”.
Could someone please tell me what I’m doing wrong in the below template?
my_download_speed:
friendly_name: 'My Download Speed'
value_template: "{{ state_attr('sensor.my_network_0_bps_received') | multiply(0.0000001) | float }}"
unit_of_measurement: "Mbps"
hass
May 15, 2020, 1:04am
2
What’s the value of {{ state_attr('sensor.my_network_0_bps_received') }}
when checked under Template in Developer Tools? I think that should be a state and note state_attr.
mkanet
(MKANET)
May 15, 2020, 1:42am
3
This is what it looks like exactly below. That numeric value changes every second.
hass
May 15, 2020, 2:20am
4
It should be:
{{ states('sensor.my_network_0_bps_received') | multiply(0.0000001) | float }}
hass
May 15, 2020, 2:26am
5
Check the code in the template editor.
1 Like
mkanet
(MKANET)
May 15, 2020, 3:02am
6
I’m not sure if you’re still reading this… but do you know how I can round the value to a hundredth of a decimal place?
I tried the below line, but the value stays at zero:
value_template: "{{ states('sensor.horizon_network_0_bps_sent') | multiply(0.0000001) | float | round(3) }}"
hass
May 15, 2020, 4:05am
7
Remove the float
. round() returns float by default. But that function should actual return with a precision of 3.