Revert "Add assistant filter to expose entities list command" (#138867)

Revert "Add assistant filter to expose entities list command (#138817)"

This reverts commit a6bb5dbe2a.
pull/138878/head
Erik Montnemery 2025-02-19 18:13:36 +01:00 committed by GitHub
parent 85f44fa008
commit 81c909e8ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 74 deletions

View File

@ -432,7 +432,6 @@ def ws_expose_entity(
@websocket_api.websocket_command(
{
vol.Required("type"): "homeassistant/expose_entity/list",
vol.Optional("assistant"): vol.In(KNOWN_ASSISTANTS),
}
)
def ws_list_exposed_entities(
@ -442,18 +441,10 @@ def ws_list_exposed_entities(
result: dict[str, Any] = {}
exposed_entities = hass.data[DATA_EXPOSED_ENTITIES]
required_assistant = msg.get("assistant")
entity_registry = er.async_get(hass)
for entity_id in chain(exposed_entities.entities, entity_registry.entities):
entity_settings = async_get_entity_settings(hass, entity_id)
if required_assistant and (
(required_assistant not in entity_settings)
or (not entity_settings[required_assistant].get("should_expose"))
):
# Not exposed to required assistant
continue
result[entity_id] = {}
entity_settings = async_get_entity_settings(hass, entity_id)
for assistant, settings in entity_settings.items():
if "should_expose" not in settings:
continue

View File

@ -539,70 +539,6 @@ async def test_list_exposed_entities(
}
async def test_list_exposed_entities_with_filter(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test list exposed entities with filter."""
ws_client = await hass_ws_client(hass)
assert await async_setup_component(hass, "homeassistant", {})
await hass.async_block_till_done()
entry1 = entity_registry.async_get_or_create("test", "test", "unique1")
entry2 = entity_registry.async_get_or_create("test", "test", "unique2")
# Expose 1 to Alexa
await ws_client.send_json_auto_id(
{
"type": "homeassistant/expose_entity",
"assistants": ["cloud.alexa"],
"entity_ids": [entry1.entity_id],
"should_expose": True,
}
)
response = await ws_client.receive_json()
assert response["success"]
# Expose 2 to Google
await ws_client.send_json_auto_id(
{
"type": "homeassistant/expose_entity",
"assistants": ["cloud.google_assistant"],
"entity_ids": [entry2.entity_id],
"should_expose": True,
}
)
response = await ws_client.receive_json()
assert response["success"]
# List with filter
await ws_client.send_json_auto_id(
{"type": "homeassistant/expose_entity/list", "assistant": "cloud.alexa"}
)
response = await ws_client.receive_json()
assert response["success"]
assert response["result"] == {
"exposed_entities": {
"test.test_unique1": {"cloud.alexa": True},
},
}
await ws_client.send_json_auto_id(
{
"type": "homeassistant/expose_entity/list",
"assistant": "cloud.google_assistant",
}
)
response = await ws_client.receive_json()
assert response["success"]
assert response["result"] == {
"exposed_entities": {
"test.test_unique2": {"cloud.google_assistant": True},
},
}
async def test_listeners(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None: