mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Keep expose setting in sync for assist (#92158)
* Keep expose setting in sync for assist * Fix initialization, add test * Fix tests * Add AgentManager.async_setup * Fix typo --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
@@ -4,6 +4,9 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import conversation
|
||||
from homeassistant.components.homeassistant.exposed_entities import (
|
||||
async_get_assistant_settings,
|
||||
)
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||
from homeassistant.core import DOMAIN as HASS_DOMAIN, Context, HomeAssistant
|
||||
from homeassistant.helpers import (
|
||||
@@ -137,3 +140,34 @@ async def test_conversation_agent(
|
||||
return_value={"homeassistant": ["dwarvish", "elvish", "entish"]},
|
||||
):
|
||||
assert agent.supported_languages == ["dwarvish", "elvish", "entish"]
|
||||
|
||||
|
||||
async def test_expose_flag_automatically_set(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test DefaultAgent sets the expose flag on all entities automatically."""
|
||||
assert await async_setup_component(hass, "homeassistant", {})
|
||||
|
||||
light = entity_registry.async_get_or_create("light", "demo", "1234")
|
||||
test = entity_registry.async_get_or_create("test", "demo", "1234")
|
||||
|
||||
assert async_get_assistant_settings(hass, conversation.DOMAIN) == {}
|
||||
|
||||
assert await async_setup_component(hass, "conversation", {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# After setting up conversation, the expose flag should now be set on all entities
|
||||
assert async_get_assistant_settings(hass, conversation.DOMAIN) == {
|
||||
light.entity_id: {"should_expose": True},
|
||||
test.entity_id: {"should_expose": False},
|
||||
}
|
||||
|
||||
# New entities will automatically have the expose flag set
|
||||
new_light = entity_registry.async_get_or_create("light", "demo", "2345")
|
||||
await hass.async_block_till_done()
|
||||
assert async_get_assistant_settings(hass, conversation.DOMAIN) == {
|
||||
light.entity_id: {"should_expose": True},
|
||||
new_light.entity_id: {"should_expose": True},
|
||||
test.entity_id: {"should_expose": False},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user