mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Revert "Add assistant filter to expose entities list command" (#138867)
Revert "Add assistant filter to expose entities list command (#138817)" This reverts commit a6bb5dbe2a9a49ae2813e281a95a5ae5033a439f.
This commit is contained in:
parent
85f44fa008
commit
81c909e8ce
@ -432,7 +432,6 @@ def ws_expose_entity(
|
|||||||
@websocket_api.websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
vol.Required("type"): "homeassistant/expose_entity/list",
|
vol.Required("type"): "homeassistant/expose_entity/list",
|
||||||
vol.Optional("assistant"): vol.In(KNOWN_ASSISTANTS),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
def ws_list_exposed_entities(
|
def ws_list_exposed_entities(
|
||||||
@ -442,18 +441,10 @@ def ws_list_exposed_entities(
|
|||||||
result: dict[str, Any] = {}
|
result: dict[str, Any] = {}
|
||||||
|
|
||||||
exposed_entities = hass.data[DATA_EXPOSED_ENTITIES]
|
exposed_entities = hass.data[DATA_EXPOSED_ENTITIES]
|
||||||
required_assistant = msg.get("assistant")
|
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
for entity_id in chain(exposed_entities.entities, entity_registry.entities):
|
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] = {}
|
result[entity_id] = {}
|
||||||
|
entity_settings = async_get_entity_settings(hass, entity_id)
|
||||||
for assistant, settings in entity_settings.items():
|
for assistant, settings in entity_settings.items():
|
||||||
if "should_expose" not in settings:
|
if "should_expose" not in settings:
|
||||||
continue
|
continue
|
||||||
|
@ -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(
|
async def test_listeners(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user