Skip to content

Commit

Permalink
hotfix history view on missing state (#11663)
Browse files Browse the repository at this point in the history
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
  • Loading branch information
lintaba and balloob committed Feb 12, 2022
1 parent bef6591 commit d86a18b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/common/entity/compute_state_display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit d86a18b

Please sign in to comment.