I’m trying to convert the “velocity” attribute from owntracks which seems to be in km/h to mph.
I have searched a bunch, but I am not a programmer so I’m a bit lost on the correct way to do this.
I’m running 0.113.2 supervised install if it matters.
and what this does is divide by 2.
So if we are going 100 km/h it says 50 mph when it should be 62 mph. 101 then 50.5 which I thought the round(0) would round to a whole number.
Should it be and int rather than float? I went with float because examples all seem to use float.
…however if I leave that “)” behind the 10 then the configuration check fails. Passes without it. So either the docs need to be updated or I messed up somewhere else.
So anybody with a grip on how this all works have any suggestions for me?
You just need some more parentheses. Try this, it worked for me when playing in the Template tab of Developer Tools: {{ (state_attr('device_tracker.mom', 'velocity') | float / 1.609) | round(0) }}
Thanks for responding guys…problem is that adding this “)” is when it fails the config check on 0.113.2.
I wonder what is going on there. I’ll have to go reread the release notes.
Maybe I’ll just have to try it and see if it goes into safe mode.
Hehehe…no. I missed it.
It works now.
So to try and understand with my non programmer mind here… is this saying that it will take the attribute of the entity as a float value then divide by 1.609 and then after that calculation is done take the result of that and round it? Was this all an order of operations thing? I just don’t get why it was dividing by 2 before.