diff --git a/src/data/translation.ts b/src/data/translation.ts index bc8165578a99..e4824b0e636f 100644 --- a/src/data/translation.ts +++ b/src/data/translation.ts @@ -61,6 +61,7 @@ export type TranslationCategory = | "state" | "entity" | "entity_component" + | "exceptions" | "config" | "config_panel" | "options" diff --git a/src/state/connection-mixin.ts b/src/state/connection-mixin.ts index c3cced5705c8..2ba9833bd69e 100644 --- a/src/state/connection-mixin.ts +++ b/src/state/connection-mixin.ts @@ -122,18 +122,27 @@ export const connectionMixin = >( } if (notifyOnError) { forwardHaptic("failure"); + const lokalize = await this.hass!.loadBackendTranslation( + "exceptions", + err.translation_domain + ); + const localizedErrorMessage = lokalize( + `component.${err.translation_domain}.exceptions.${err.translation_key}.message`, + err.translation_placeholders + ); const message = + localizedErrorMessage || (this as any).hass.localize( "ui.notification_toast.service_call_failed", "service", `${domain}/${service}` ) + - ` ${ - err.message || - (err.error?.code === ERR_CONNECTION_LOST - ? "connection lost" - : "unknown error") - }`; + ` ${ + err.message || + (err.error?.code === ERR_CONNECTION_LOST + ? "connection lost" + : "unknown error") + }`; fireEvent(this as any, "hass-notification", { message }); } throw err;