Restore original websocket commands for config entries (#93707)

Restore original websocket commands and add "config_entries/get_single"
This commit is contained in:
Marvin Wichmann 2023-05-29 03:40:35 +02:00 committed by GitHub
parent 5f584d5dbd
commit 795ef075da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 22 deletions

View file

@ -41,9 +41,9 @@ async def async_setup(hass):
hass.http.register_view(OptionManagerFlowIndexView(hass.config_entries.options)) hass.http.register_view(OptionManagerFlowIndexView(hass.config_entries.options))
hass.http.register_view(OptionManagerFlowResourceView(hass.config_entries.options)) hass.http.register_view(OptionManagerFlowResourceView(hass.config_entries.options))
websocket_api.async_register_command(hass, config_entries_get_matching) websocket_api.async_register_command(hass, config_entries_get)
websocket_api.async_register_command(hass, config_entry_disable) websocket_api.async_register_command(hass, config_entry_disable)
websocket_api.async_register_command(hass, config_entry_get) websocket_api.async_register_command(hass, config_entry_get_single)
websocket_api.async_register_command(hass, config_entry_update) websocket_api.async_register_command(hass, config_entry_update)
websocket_api.async_register_command(hass, config_entries_subscribe) websocket_api.async_register_command(hass, config_entries_subscribe)
websocket_api.async_register_command(hass, config_entries_progress) websocket_api.async_register_command(hass, config_entries_progress)
@ -288,12 +288,12 @@ def get_entry(
@websocket_api.require_admin @websocket_api.require_admin
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
"type": "config_entries/get", "type": "config_entries/get_single",
"entry_id": str, "entry_id": str,
} }
) )
@websocket_api.async_response @websocket_api.async_response
async def config_entry_get( async def config_entry_get_single(
hass: HomeAssistant, hass: HomeAssistant,
connection: websocket_api.ActiveConnection, connection: websocket_api.ActiveConnection,
msg: dict[str, Any], msg: dict[str, Any],
@ -432,13 +432,13 @@ async def ignore_config_flow(
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
vol.Required("type"): "config_entries/get_matching", vol.Required("type"): "config_entries/get",
vol.Optional("type_filter"): vol.All(cv.ensure_list, [str]), vol.Optional("type_filter"): vol.All(cv.ensure_list, [str]),
vol.Optional("domain"): str, vol.Optional("domain"): str,
} }
) )
@websocket_api.async_response @websocket_api.async_response
async def config_entries_get_matching( async def config_entries_get(
hass: HomeAssistant, hass: HomeAssistant,
connection: websocket_api.ActiveConnection, connection: websocket_api.ActiveConnection,
msg: dict[str, Any], msg: dict[str, Any],

View file

@ -36,7 +36,7 @@ async def test_options_flow_disabled_not_setup(
await ws_client.send_json( await ws_client.send_json(
{ {
"id": 5, "id": 5,
"type": "config_entries/get_matching", "type": "config_entries/get",
"domain": "bluetooth", "domain": "bluetooth",
} }
) )
@ -370,7 +370,7 @@ async def test_options_flow_disabled_macos(
await ws_client.send_json( await ws_client.send_json(
{ {
"id": 5, "id": 5,
"type": "config_entries/get_matching", "type": "config_entries/get",
"domain": "bluetooth", "domain": "bluetooth",
} }
) )
@ -403,7 +403,7 @@ async def test_options_flow_enabled_linux(
await ws_client.send_json( await ws_client.send_json(
{ {
"id": 5, "id": 5,
"type": "config_entries/get_matching", "type": "config_entries/get",
"domain": "bluetooth", "domain": "bluetooth",
} }
) )

View file

@ -969,7 +969,9 @@ async def test_options_flow_with_invalid_data(hass: HomeAssistant, client) -> No
} }
async def test_get(hass: HomeAssistant, hass_ws_client: WebSocketGenerator) -> None: async def test_get_single(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
) -> None:
"""Test that we can get a config entry.""" """Test that we can get a config entry."""
assert await async_setup_component(hass, "config", {}) assert await async_setup_component(hass, "config", {})
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
@ -982,7 +984,7 @@ async def test_get(hass: HomeAssistant, hass_ws_client: WebSocketGenerator) -> N
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get", "type": "config_entries/get_single",
"entry_id": entry.entry_id, "entry_id": entry.entry_id,
} }
) )
@ -1006,7 +1008,7 @@ async def test_get(hass: HomeAssistant, hass_ws_client: WebSocketGenerator) -> N
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get", "type": "config_entries/get_single",
"entry_id": "blah", "entry_id": "blah",
} }
) )
@ -1317,7 +1319,7 @@ async def test_get_matching_entries_ws(
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
await ws_client.send_json_auto_id({"type": "config_entries/get_matching"}) await ws_client.send_json_auto_id({"type": "config_entries/get"})
response = await ws_client.receive_json() response = await ws_client.receive_json()
assert response["result"] == [ assert response["result"] == [
{ {
@ -1394,7 +1396,7 @@ async def test_get_matching_entries_ws(
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get_matching", "type": "config_entries/get",
"domain": "comp1", "domain": "comp1",
"type_filter": "hub", "type_filter": "hub",
} }
@ -1419,7 +1421,7 @@ async def test_get_matching_entries_ws(
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get_matching", "type": "config_entries/get",
"type_filter": ["service", "device"], "type_filter": ["service", "device"],
} }
) )
@ -1457,7 +1459,7 @@ async def test_get_matching_entries_ws(
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get_matching", "type": "config_entries/get",
"type_filter": "hub", "type_filter": "hub",
} }
) )
@ -1500,7 +1502,7 @@ async def test_get_matching_entries_ws(
): ):
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get_matching", "type": "config_entries/get",
"type_filter": "hub", "type_filter": "hub",
} }
) )
@ -1586,7 +1588,7 @@ async def test_get_matching_entries_ws(
): ):
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get_matching", "type": "config_entries/get",
"type_filter": ["helper"], "type_filter": ["helper"],
} }
) )
@ -1602,7 +1604,7 @@ async def test_get_matching_entries_ws(
): ):
await ws_client.send_json_auto_id( await ws_client.send_json_auto_id(
{ {
"type": "config_entries/get_matching", "type": "config_entries/get",
"type_filter": ["device", "hub", "service"], "type_filter": ["device", "hub", "service"],
} }
) )

View file

@ -858,7 +858,7 @@ async def test_options_flow_disabled_gen_1(
await ws_client.send_json( await ws_client.send_json(
{ {
"id": 5, "id": 5,
"type": "config_entries/get_matching", "type": "config_entries/get",
"domain": "shelly", "domain": "shelly",
} }
) )
@ -879,7 +879,7 @@ async def test_options_flow_enabled_gen_2(
await ws_client.send_json( await ws_client.send_json(
{ {
"id": 5, "id": 5,
"type": "config_entries/get_matching", "type": "config_entries/get",
"domain": "shelly", "domain": "shelly",
} }
) )
@ -900,7 +900,7 @@ async def test_options_flow_disabled_sleepy_gen_2(
await ws_client.send_json( await ws_client.send_json(
{ {
"id": 5, "id": 5,
"type": "config_entries/get_matching", "type": "config_entries/get",
"domain": "shelly", "domain": "shelly",
} }
) )