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

Fix states not being translated
This commit is contained in:
Tudor Sandu 2023-06-02 03:10:57 +03:00 committed by GitHub
parent 8ef799601b
commit 95e4ef2255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,13 +278,13 @@ class DefaultAgent(AbstractConversationAgent):
all_states = matched + unmatched all_states = matched + unmatched
domains = {state.domain for state in all_states} domains = {state.domain for state in all_states}
translations = await translation.async_get_translations( translations = await translation.async_get_translations(
self.hass, language, "state", domains self.hass, language, "entity_component", domains
) )
# Use translated state names # Use translated state names
for state in all_states: for state in all_states:
device_class = state.attributes.get("device_class", "_") 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) state.state = translations.get(key, state.state)
# Get first matched or unmatched state. # Get first matched or unmatched state.