From a5cd350d250d8d7a6296eff462712365d3b8b480 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 31 Jul 2023 13:31:39 +0200 Subject: [PATCH] Fix unknown event type bug (#17426) * Fix unknown event type bug * Update src/data/logbook.ts Co-authored-by: Bram Kragten --------- Co-authored-by: Bram Kragten --- src/data/logbook.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/data/logbook.ts b/src/data/logbook.ts index 75deda104e..1a493f0dba 100644 --- a/src/data/logbook.ts +++ b/src/data/logbook.ts @@ -346,16 +346,18 @@ export const localizeStateMessage = ( break; case "event": { - const event_type = - computeAttributeValueDisplay( - hass!.localize, - stateObj, - hass.locale, - hass.config, - hass.entities, - "event_type" - )?.toString() || - localize(`${LOGBOOK_LOCALIZE_PATH}.detected_unknown_event`); + const event_type = computeAttributeValueDisplay( + hass!.localize, + stateObj, + hass.locale, + hass.config, + hass.entities, + "event_type" + )?.toString(); + + if (!event_type) { + return localize(`${LOGBOOK_LOCALIZE_PATH}.detected_unknown_event`); + } return localize(`${LOGBOOK_LOCALIZE_PATH}.detected_event`, { event_type: autoCaseNoun(event_type, hass.language),