From 711286f7c0310ccecdc2e8fbdb7deb3e8ac7d564 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Tue, 24 Jan 2023 08:16:03 -0800 Subject: [PATCH] Round battery values in device table to whole numbers (to fit in the column width) (#14927) * Increase battery column width to fit 100.0% * drop trailing 0s from battery decimals * round values to whole numbers --- src/panels/config/devices/ha-config-devices-dashboard.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/panels/config/devices/ha-config-devices-dashboard.ts b/src/panels/config/devices/ha-config-devices-dashboard.ts index 1ca95f1141..b336bf6b18 100644 --- a/src/panels/config/devices/ha-config-devices-dashboard.ts +++ b/src/panels/config/devices/ha-config-devices-dashboard.ts @@ -338,11 +338,14 @@ export class HaConfigDeviceDashboard extends LitElement { : undefined; const batteryIsBinary = battery && computeStateDomain(battery) === "binary_sensor"; + return battery && (batteryIsBinary || !isNaN(battery.state as any)) ? html` ${batteryIsBinary ? "" - : battery.state + blankBeforePercent(this.hass.locale) + "%"} + : Number(battery.state).toFixed() + + blankBeforePercent(this.hass.locale) + + "%"}