I have a handful of entities report in one unit of measurement, but I want to see them in another. For instance, I have a rain gauge that reports rainfall in mm, but I want to see it in inches. But to do this I need to make a whole new entity just to do the conversion? Why?!
The same for example with electricity price which usually comes from sensor in Euros (or whatever local currency is) but being always less than one would be much better to see in cents.
Pretty sure you can use JavaScript to do that. I’m mobile right now so can’t easily provide an example but search the forums for “JavaScript in Lovelace” and you should find a few snippets to get you started.
Terry
I think it is possible only in some specific cards. Not every card support such customization.
This shouldn’t be handled in lovelace, you should be able to select it directly from each integration. There are plenty of places I need to use sensors outside of lovelace. But I agree we need some conversion built in. Here’s the text of my similar WTH post that got redirected to here:
"Over the last few years I’ve watched as the devs have continually changed their minds about what units things like temperature, pressure, and even air quality are measured in. Every time you change it, it breaks something for me.
My question to you, why don’t you manage this in an internal way which standardizes it internally, but allows the user to decide which units their sensors will be displayed in, so that when you mess with things in the back end, it doesn’t mess up things for me?
Certainly unit conversion is not a very difficult feature to add?"
Note that some sensors already allow you to change the unit on a per-entity basis, but I suppose that you might still want to use a different-to-normal unit in some specific dashboards.
It’s being dealt with one after the other.
Then the integration sets a “base” UoM and the user can select something else (where conversion applies) on the entity.
I think this only works for temperature.
Temperature was the first sensor type that gained support for this, but now others have it too (e.g. pressure).
Maybe we can get a conversion helper that can do a linear conversion of an entity?
You provide an offset, scalar, unit and entity, and it creates a new entity with the value of the entity multiplied by the scalar and offset added to it and new unit applied.
This seems closer to the Home Assistant way of doing things.
Already exists, you can do non-linear as well. Compensation integration.