WTH - Why do I have to set up templates to convert units?

Tags: #<Tag:0x00007fc41724b778>

I am implementing a Netatmo Anemometer to measure wind. The Netatmo app lets its users choose what units they want to display the data in (km/h, m/s, miles/h, Beaufort or Knots).
But in HA, I have to set up a template sensor to convert the data??
I guess this could be fixed using an option in the Lovelace card? Or maybe even the Netatmo API lets HA check what units the user has chosen!?

Yes please! Convert data directly in Lovelace

While I 100% want this, I have to point out that would require major changes. Especially if we wanted units to change on an individual sensor basis. Essentially each sensor would need ‘user units’, ‘input units (from hardware)’, and a conversion equation for this to work. Maybe this could make it easier to implement…

Edit: There’s also this. Seems a bit easier but it would require some very specific unit types.

Lovelace is mostly client side javascript and unit conversion is very simple math… Provide an optional input that lets the user perform an math operation in javascript. If you wanted to get fancy and the integration knows the current unit, you could present presets but really most of the time I just want to convert seconds to Minutes or something simple.

IMO ideal situation would be if data stored in sensors are always normalized to some system of units. Let’s say SI.
It would makes easier then to manage conversion on FEs. It obviously has more profits than this one. AFAIK current HA can store temperature in Bars and the system doesn’t care about it. Which works but has limitations if you start to transform/compare those data etc.

Yes, this is what most softwares do. System units under the hood in the backend and user units in the UI. It’s no easy change, it would be rather large. It would also screw up all the current databases.

OK if making it know units is hard just give us a simple math transform in JavaScript or something.

You could even over simplify it to only multiply and divide functions… as that is mostly what unit conversion is.