From 81c909e8ce2dc56210dd5a72e5ca33bd213879be Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 19 Feb 2025 18:13:36 +0100 Subject: [PATCH] Revert "Add assistant filter to expose entities list command" (#138867) Revert "Add assistant filter to expose entities list command (#138817)" This reverts commit a6bb5dbe2a9a49ae2813e281a95a5ae5033a439f. --- .../homeassistant/exposed_entities.py | 11 +--- .../homeassistant/test_exposed_entities.py | 64 ------------------- 2 files changed, 1 insertion(+), 74 deletions(-) diff --git a/homeassistant/components/homeassistant/exposed_entities.py b/homeassistant/components/homeassistant/exposed_entities.py index 0c815502669..7bd9f9ab7bc 100644 --- a/homeassistant/components/homeassistant/exposed_entities.py +++ b/homeassistant/components/homeassistant/exposed_entities.py @@ -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 diff --git a/tests/components/homeassistant/test_exposed_entities.py b/tests/components/homeassistant/test_exposed_entities.py index 0c57aad58ea..1f1955c2f82 100644 --- a/tests/components/homeassistant/test_exposed_entities.py +++ b/tests/components/homeassistant/test_exposed_entities.py @@ -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: