Conversation reload with language=None clears all languages (#103757)
Reload with language=None clears all languages
This commit is contained in:
parent
253e6188eb
commit
e157206eeb
2 changed files with 13 additions and 5 deletions
|
@ -368,10 +368,11 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
async def async_reload(self, language: str | None = None):
|
||||
"""Clear cached intents for a language."""
|
||||
if language is None:
|
||||
language = self.hass.config.language
|
||||
|
||||
self._lang_intents.pop(language, None)
|
||||
_LOGGER.debug("Cleared intents for language: %s", language)
|
||||
self._lang_intents.clear()
|
||||
_LOGGER.debug("Cleared intents for all languages")
|
||||
else:
|
||||
self._lang_intents.pop(language, None)
|
||||
_LOGGER.debug("Cleared intents for language: %s", language)
|
||||
|
||||
async def async_prepare(self, language: str | None = None):
|
||||
"""Load intents for a language."""
|
||||
|
|
|
@ -1307,7 +1307,14 @@ async def test_prepare_reload(hass: HomeAssistant) -> None:
|
|||
# Confirm intents are loaded
|
||||
assert agent._lang_intents.get(language)
|
||||
|
||||
# Clear cache
|
||||
# Try to clear for a different language
|
||||
await hass.services.async_call("conversation", "reload", {"language": "elvish"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Confirm intents are still loaded
|
||||
assert agent._lang_intents.get(language)
|
||||
|
||||
# Clear cache for all languages
|
||||
await hass.services.async_call("conversation", "reload", {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue