benct / lovelace-multiple-entity-row

Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UI
MIT License
768 stars 55 forks source link

Feature Request: Format - Percent? #323

Open kylepyke opened 6 months ago

kylepyke commented 6 months ago

I'm wondering if it's possible in a future release to add a percent value to the format: option, to convert single decimal places to percentage. For example, 0.3 would become 30%.

This would be helpful for, say displaying volume for a media_player.

Thanks for all of your work on this repo!

michluk commented 2 months ago

I came across this idea as well and would place a +1 for this feature.

I think adding something like

...
else if (config.format === 'percent') {
            value = Math.round(value * 100);
            unit = '%';
...

to the formatting part of the code (https://github.com/benct/lovelace-multiple-entity-row/blob/a3302f2778aa9a0b9e88cd829fc68e950da992fc/src/entity.js#L40) would already suffice.

Unfortunately, I am not into JS deployment. Therefore I would motivate someone else to look into this more deeply :-)