Ensure numeric attributes are formatted correctly (#11336)

This commit is contained in:
Philip Allgaier 2022-01-17 06:21:04 +01:00 committed by GitHub
parent 9fffc93e5d
commit 52588a3915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { until } from "lit/directives/until";
import checkValidDate from "../common/datetime/check_valid_date";
import { formatDate } from "../common/datetime/format_date";
import { formatDateTimeWithSeconds } from "../common/datetime/format_date_time";
import { formatNumber } from "../common/number/format_number";
import { capitalizeFirstLetter } from "../common/string/capitalize-first-letter";
import { isDate } from "../common/string/is_date";
import { isTimestamp } from "../common/string/is_timestamp";
@ -190,6 +191,10 @@ export function formatAttributeValue(
return html`<pre>${until(yaml, "")}</pre>`;
}
if (typeof value === "number") {
return formatNumber(value, hass.locale);
}
if (typeof value === "string") {
// URL handling
if (value.startsWith("http")) {