Reload conversation entries on update (#123279)

pull/123276/head
Paulus Schoutsen 2024-08-07 11:18:48 +02:00 committed by Franck Nijhof
parent 270990fe39
commit db32460f3b
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
4 changed files with 6 additions and 12 deletions

View File

@ -346,9 +346,5 @@ class OllamaConversationEntity(
self, hass: HomeAssistant, entry: ConfigEntry
) -> None:
"""Handle options update."""
if entry.options.get(CONF_LLM_HASS_API):
self._attr_supported_features = (
conversation.ConversationEntityFeature.CONTROL
)
else:
self._attr_supported_features = conversation.ConversationEntityFeature(0)
# Reload as we update device info + entity name + supported features
await hass.config_entries.async_reload(entry.entry_id)

View File

@ -328,9 +328,5 @@ class OpenAIConversationEntity(
self, hass: HomeAssistant, entry: ConfigEntry
) -> None:
"""Handle options update."""
if entry.options.get(CONF_LLM_HASS_API):
self._attr_supported_features = (
conversation.ConversationEntityFeature.CONTROL
)
else:
self._attr_supported_features = conversation.ConversationEntityFeature(0)
# Reload as we update device info + entity name + supported features
await hass.config_entries.async_reload(entry.entry_id)

View File

@ -48,6 +48,7 @@ async def mock_init_component(hass: HomeAssistant, mock_config_entry: MockConfig
):
assert await async_setup_component(hass, ollama.DOMAIN, {})
await hass.async_block_till_done()
yield
@pytest.fixture(autouse=True)

View File

@ -312,6 +312,7 @@ async def test_unknown_hass_api(
CONF_LLM_HASS_API: "non-existing",
},
)
await hass.async_block_till_done()
result = await conversation.async_converse(
hass, "hello", None, Context(), agent_id=mock_config_entry.entry_id