mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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
@ -368,10 +368,11 @@ class DefaultAgent(AbstractConversationAgent):
|
|||||||
async def async_reload(self, language: str | None = None):
|
async def async_reload(self, language: str | None = None):
|
||||||
"""Clear cached intents for a language."""
|
"""Clear cached intents for a language."""
|
||||||
if language is None:
|
if language is None:
|
||||||
language = self.hass.config.language
|
self._lang_intents.clear()
|
||||||
|
_LOGGER.debug("Cleared intents for all languages")
|
||||||
self._lang_intents.pop(language, None)
|
else:
|
||||||
_LOGGER.debug("Cleared intents for language: %s", language)
|
self._lang_intents.pop(language, None)
|
||||||
|
_LOGGER.debug("Cleared intents for language: %s", language)
|
||||||
|
|
||||||
async def async_prepare(self, language: str | None = None):
|
async def async_prepare(self, language: str | None = None):
|
||||||
"""Load intents for a language."""
|
"""Load intents for a language."""
|
||||||
|
@ -1307,7 +1307,14 @@ async def test_prepare_reload(hass: HomeAssistant) -> None:
|
|||||||
# Confirm intents are loaded
|
# Confirm intents are loaded
|
||||||
assert agent._lang_intents.get(language)
|
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.services.async_call("conversation", "reload", {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user