hotfix history view on missing state (#11663)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
lintaba 2022-02-12 23:00:50 +01:00 committed by GitHub
parent bef6591548
commit d86a18b80b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,9 @@ export const computeStateDisplay = (
if (compareState === UNKNOWN || compareState === UNAVAILABLE) {
return localize(`state.default.${compareState}`);
}
if (compareState === "") {
return localize(`state.default.${UNKNOWN}`);
}
// Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
if (isNumericState(stateObj)) {
@ -123,7 +126,11 @@ export const computeStateDisplay = (
domain === "scene" ||
(domain === "sensor" && stateObj.attributes.device_class === "timestamp")
) {
return formatDateTime(new Date(compareState), locale);
try {
return formatDateTime(new Date(compareState), locale);
} catch (_err) {
return compareState;
}
}
return (