Fix states not being translated in voice assistants (#93572)

Fix states not being translated
This commit is contained in:
Tudor Sandu
2023-06-02 08:45:49 -04:00
committed by Paulus Schoutsen
parent a98094eda6
commit e58ea00ce6
@@ -278,13 +278,13 @@ class DefaultAgent(AbstractConversationAgent):
all_states = matched + unmatched
domains = {state.domain for state in all_states}
translations = await translation.async_get_translations(
self.hass, language, "state", domains
self.hass, language, "entity_component", domains
)
# Use translated state names
for state in all_states:
device_class = state.attributes.get("device_class", "_")
key = f"component.{state.domain}.state.{device_class}.{state.state}"
key = f"component.{state.domain}.entity_component.{device_class}.state.{state.state}"
state.state = translations.get(key, state.state)
# Get first matched or unmatched state.