From ae15dd678beb47ada65d71e60542855c5f5526b5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Nov 2022 08:07:50 -0600 Subject: [PATCH] Fix logbook reporting unknown states as unavailable (#14359) Co-authored-by: Paul Bottein --- src/data/logbook.ts | 8 ++++++-- src/translations/en.json | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/data/logbook.ts b/src/data/logbook.ts index 37fa183b75..6509cc5d06 100644 --- a/src/data/logbook.ts +++ b/src/data/logbook.ts @@ -10,7 +10,7 @@ import { computeStateDomain } from "../common/entity/compute_state_domain"; import { LocalizeFunc } from "../common/translations/localize"; import { HaEntityPickerEntityFilterFunc } from "../components/entity/ha-entity-picker"; import { HomeAssistant } from "../types"; -import { UNAVAILABLE_STATES } from "./entity"; +import { UNAVAILABLE, UNKNOWN } from "./entity"; const LOGBOOK_LOCALIZE_PATH = "ui.components.logbook.messages"; export const CONTINUOUS_DOMAINS = ["counter", "proximity", "sensor", "zone"]; @@ -421,7 +421,11 @@ export const localizeStateMessage = ( return localize(`${LOGBOOK_LOCALIZE_PATH}.turned_off`); } - if (UNAVAILABLE_STATES.includes(state)) { + if (state === UNKNOWN) { + return localize(`${LOGBOOK_LOCALIZE_PATH}.became_unknown`); + } + + if (state === UNAVAILABLE) { return localize(`${LOGBOOK_LOCALIZE_PATH}.became_unavailable`); } diff --git a/src/translations/en.json b/src/translations/en.json index 5833a0c573..f08f659a2d 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -391,6 +391,7 @@ "turned_on": "turned on", "changed_to_state": "changed to {state}", "became_unavailable": "became unavailable", + "became_unknown": "became unknown", "detected_tampering": "detected tampering", "cleared_tampering": "cleared tampering" }