Fix unknown event type bug (#17426)

* Fix unknown event type bug

* Update src/data/logbook.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Joost Lekkerkerker 2023-07-31 13:31:39 +02:00 committed by GitHub
parent 0ee231ee85
commit a5cd350d25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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),