Add support for specifying the integrations manifest/list fetches (#71982)
* Add support for specifying the integrations manifest/list fetches See https://github.com/home-assistant/core/pull/71979 for the motovation * Update homeassistant/components/websocket_api/commands.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>pull/71988/head
parent
ddecf76f6f
commit
78f0716574
|
@ -359,15 +359,19 @@ def handle_get_config(
|
|||
connection.send_result(msg["id"], hass.config.as_dict())
|
||||
|
||||
|
||||
@decorators.websocket_command({vol.Required("type"): "manifest/list"})
|
||||
@decorators.websocket_command(
|
||||
{vol.Required("type"): "manifest/list", vol.Optional("integrations"): [str]}
|
||||
)
|
||||
@decorators.async_response
|
||||
async def handle_manifest_list(
|
||||
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
|
||||
) -> None:
|
||||
"""Handle integrations command."""
|
||||
loaded_integrations = async_get_loaded_integrations(hass)
|
||||
wanted_integrations = msg.get("integrations")
|
||||
if wanted_integrations is None:
|
||||
wanted_integrations = async_get_loaded_integrations(hass)
|
||||
integrations = await asyncio.gather(
|
||||
*(async_get_integration(hass, domain) for domain in loaded_integrations)
|
||||
*(async_get_integration(hass, domain) for domain in wanted_integrations)
|
||||
)
|
||||
connection.send_result(
|
||||
msg["id"], [integration.manifest for integration in integrations]
|
||||
|
|
|
@ -1351,6 +1351,25 @@ async def test_manifest_list(hass, websocket_client):
|
|||
]
|
||||
|
||||
|
||||
async def test_manifest_list_specific_integrations(hass, websocket_client):
|
||||
"""Test loading manifests for specific integrations."""
|
||||
websocket_api = await async_get_integration(hass, "websocket_api")
|
||||
|
||||
await websocket_client.send_json(
|
||||
{"id": 5, "type": "manifest/list", "integrations": ["hue", "websocket_api"]}
|
||||
)
|
||||
hue = await async_get_integration(hass, "hue")
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == 5
|
||||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert msg["success"]
|
||||
assert sorted(msg["result"], key=lambda manifest: manifest["domain"]) == [
|
||||
hue.manifest,
|
||||
websocket_api.manifest,
|
||||
]
|
||||
|
||||
|
||||
async def test_manifest_get(hass, websocket_client):
|
||||
"""Test getting a manifest."""
|
||||
hue = await async_get_integration(hass, "hue")
|
||||
|
|
Loading…
Reference in New Issue