Add WS command for getting a config entry (#93387)
* Add WS command for getting a config entry * Update tests
This commit is contained in:
parent
657d285e8f
commit
b754f03eb1
4 changed files with 95 additions and 41 deletions
|
@ -41,8 +41,9 @@ async def async_setup(hass):
|
|||
hass.http.register_view(OptionManagerFlowIndexView(hass.config_entries.options))
|
||||
hass.http.register_view(OptionManagerFlowResourceView(hass.config_entries.options))
|
||||
|
||||
websocket_api.async_register_command(hass, config_entries_get)
|
||||
websocket_api.async_register_command(hass, config_entries_get_matching)
|
||||
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_update)
|
||||
websocket_api.async_register_command(hass, config_entries_subscribe)
|
||||
websocket_api.async_register_command(hass, config_entries_progress)
|
||||
|
@ -284,6 +285,28 @@ def get_entry(
|
|||
return entry
|
||||
|
||||
|
||||
@websocket_api.require_admin
|
||||
@websocket_api.websocket_command(
|
||||
{
|
||||
"type": "config_entries/get",
|
||||
"entry_id": str,
|
||||
}
|
||||
)
|
||||
@websocket_api.async_response
|
||||
async def config_entry_get(
|
||||
hass: HomeAssistant,
|
||||
connection: websocket_api.ActiveConnection,
|
||||
msg: dict[str, Any],
|
||||
) -> None:
|
||||
"""Update config entry."""
|
||||
entry = get_entry(hass, connection, msg["entry_id"], msg["id"])
|
||||
if entry is None:
|
||||
return
|
||||
|
||||
result = {"config_entry": entry_json(entry)}
|
||||
connection.send_result(msg["id"], result)
|
||||
|
||||
|
||||
@websocket_api.require_admin
|
||||
@websocket_api.websocket_command(
|
||||
{
|
||||
|
@ -409,13 +432,13 @@ async def ignore_config_flow(
|
|||
|
||||
@websocket_api.websocket_command(
|
||||
{
|
||||
vol.Required("type"): "config_entries/get",
|
||||
vol.Required("type"): "config_entries/get_matching",
|
||||
vol.Optional("type_filter"): vol.All(cv.ensure_list, [str]),
|
||||
vol.Optional("domain"): str,
|
||||
}
|
||||
)
|
||||
@websocket_api.async_response
|
||||
async def config_entries_get(
|
||||
async def config_entries_get_matching(
|
||||
hass: HomeAssistant,
|
||||
connection: websocket_api.ActiveConnection,
|
||||
msg: dict[str, Any],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue