Import websocket_api (part 1) (#63905)

This commit is contained in:
Erik Montnemery 2022-01-11 18:24:08 +01:00 committed by GitHub
parent 4460aef040
commit 9c9dc4cb8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 57 deletions

View File

@ -196,24 +196,26 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.http.register_view(TokenView(retrieve_result)) hass.http.register_view(TokenView(retrieve_result))
hass.http.register_view(LinkUserView(retrieve_result)) hass.http.register_view(LinkUserView(retrieve_result))
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_CURRENT_USER, websocket_current_user, SCHEMA_WS_CURRENT_USER hass, WS_TYPE_CURRENT_USER, websocket_current_user, SCHEMA_WS_CURRENT_USER
) )
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
hass,
WS_TYPE_LONG_LIVED_ACCESS_TOKEN, WS_TYPE_LONG_LIVED_ACCESS_TOKEN,
websocket_create_long_lived_access_token, websocket_create_long_lived_access_token,
SCHEMA_WS_LONG_LIVED_ACCESS_TOKEN, SCHEMA_WS_LONG_LIVED_ACCESS_TOKEN,
) )
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_REFRESH_TOKENS, websocket_refresh_tokens, SCHEMA_WS_REFRESH_TOKENS hass, WS_TYPE_REFRESH_TOKENS, websocket_refresh_tokens, SCHEMA_WS_REFRESH_TOKENS
) )
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
hass,
WS_TYPE_DELETE_REFRESH_TOKEN, WS_TYPE_DELETE_REFRESH_TOKEN,
websocket_delete_refresh_token, websocket_delete_refresh_token,
SCHEMA_WS_DELETE_REFRESH_TOKEN, SCHEMA_WS_DELETE_REFRESH_TOKEN,
) )
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_SIGN_PATH, websocket_sign_path, SCHEMA_WS_SIGN_PATH hass, WS_TYPE_SIGN_PATH, websocket_sign_path, SCHEMA_WS_SIGN_PATH
) )
await login_flow.async_setup(hass, store_result) await login_flow.async_setup(hass, store_result)

View File

@ -50,12 +50,12 @@ async def async_setup(hass):
"""Init mfa setup flow manager.""" """Init mfa setup flow manager."""
hass.data[DATA_SETUP_FLOW_MGR] = MfaFlowManager(hass) hass.data[DATA_SETUP_FLOW_MGR] = MfaFlowManager(hass)
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_SETUP_MFA, websocket_setup_mfa, SCHEMA_WS_SETUP_MFA hass, WS_TYPE_SETUP_MFA, websocket_setup_mfa, SCHEMA_WS_SETUP_MFA
) )
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_DEPOSE_MFA, websocket_depose_mfa, SCHEMA_WS_DEPOSE_MFA hass, WS_TYPE_DEPOSE_MFA, websocket_depose_mfa, SCHEMA_WS_DEPOSE_MFA
) )

View File

@ -353,13 +353,16 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.http.register_view(CameraImageView(component)) hass.http.register_view(CameraImageView(component))
hass.http.register_view(CameraMjpegStream(component)) hass.http.register_view(CameraMjpegStream(component))
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_CAMERA_THUMBNAIL, websocket_camera_thumbnail, SCHEMA_WS_CAMERA_THUMBNAIL hass,
WS_TYPE_CAMERA_THUMBNAIL,
websocket_camera_thumbnail,
SCHEMA_WS_CAMERA_THUMBNAIL,
) )
hass.components.websocket_api.async_register_command(ws_camera_stream) websocket_api.async_register_command(hass, ws_camera_stream)
hass.components.websocket_api.async_register_command(ws_camera_web_rtc_offer) websocket_api.async_register_command(hass, ws_camera_web_rtc_offer)
hass.components.websocket_api.async_register_command(websocket_get_prefs) websocket_api.async_register_command(hass, websocket_get_prefs)
hass.components.websocket_api.async_register_command(websocket_update_prefs) websocket_api.async_register_command(hass, websocket_update_prefs)
await component.async_setup(config) await component.async_setup(config)

View File

@ -55,24 +55,23 @@ _CLOUD_ERRORS = {
async def async_setup(hass): async def async_setup(hass):
"""Initialize the HTTP API.""" """Initialize the HTTP API."""
async_register_command = hass.components.websocket_api.async_register_command websocket_api.async_register_command(hass, websocket_cloud_status)
async_register_command(websocket_cloud_status) websocket_api.async_register_command(hass, websocket_subscription)
async_register_command(websocket_subscription) websocket_api.async_register_command(hass, websocket_update_prefs)
async_register_command(websocket_update_prefs) websocket_api.async_register_command(hass, websocket_hook_create)
async_register_command(websocket_hook_create) websocket_api.async_register_command(hass, websocket_hook_delete)
async_register_command(websocket_hook_delete) websocket_api.async_register_command(hass, websocket_remote_connect)
async_register_command(websocket_remote_connect) websocket_api.async_register_command(hass, websocket_remote_disconnect)
async_register_command(websocket_remote_disconnect)
async_register_command(google_assistant_list) websocket_api.async_register_command(hass, google_assistant_list)
async_register_command(google_assistant_update) websocket_api.async_register_command(hass, google_assistant_update)
async_register_command(alexa_list) websocket_api.async_register_command(hass, alexa_list)
async_register_command(alexa_update) websocket_api.async_register_command(hass, alexa_update)
async_register_command(alexa_sync) websocket_api.async_register_command(hass, alexa_sync)
async_register_command(thingtalk_convert) websocket_api.async_register_command(hass, thingtalk_convert)
async_register_command(tts_info) websocket_api.async_register_command(hass, tts_info)
hass.http.register_view(GoogleActionsSyncView) hass.http.register_view(GoogleActionsSyncView)
hass.http.register_view(CloudLoginView) hass.http.register_view(CloudLoginView)

View File

@ -8,10 +8,10 @@ from homeassistant.helpers.area_registry import async_get
async def async_setup(hass): async def async_setup(hass):
"""Enable the Area Registry views.""" """Enable the Area Registry views."""
hass.components.websocket_api.async_register_command(websocket_list_areas) websocket_api.async_register_command(hass, websocket_list_areas)
hass.components.websocket_api.async_register_command(websocket_create_area) websocket_api.async_register_command(hass, websocket_create_area)
hass.components.websocket_api.async_register_command(websocket_delete_area) websocket_api.async_register_command(hass, websocket_delete_area)
hass.components.websocket_api.async_register_command(websocket_update_area) websocket_api.async_register_command(hass, websocket_update_area)
return True return True

View File

@ -16,14 +16,14 @@ SCHEMA_WS_DELETE = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend(
async def async_setup(hass): async def async_setup(hass):
"""Enable the Home Assistant views.""" """Enable the Home Assistant views."""
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_LIST, websocket_list, SCHEMA_WS_LIST hass, WS_TYPE_LIST, websocket_list, SCHEMA_WS_LIST
) )
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_DELETE, websocket_delete, SCHEMA_WS_DELETE hass, WS_TYPE_DELETE, websocket_delete, SCHEMA_WS_DELETE
) )
hass.components.websocket_api.async_register_command(websocket_create) websocket_api.async_register_command(hass, websocket_create)
hass.components.websocket_api.async_register_command(websocket_update) websocket_api.async_register_command(hass, websocket_update)
return True return True

View File

@ -9,12 +9,10 @@ from homeassistant.exceptions import Unauthorized
async def async_setup(hass): async def async_setup(hass):
"""Enable the Home Assistant views.""" """Enable the Home Assistant views."""
hass.components.websocket_api.async_register_command(websocket_create) websocket_api.async_register_command(hass, websocket_create)
hass.components.websocket_api.async_register_command(websocket_delete) websocket_api.async_register_command(hass, websocket_delete)
hass.components.websocket_api.async_register_command(websocket_change_password) websocket_api.async_register_command(hass, websocket_change_password)
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(hass, websocket_admin_change_password)
websocket_admin_change_password
)
return True return True

View File

@ -31,10 +31,10 @@ 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))
hass.components.websocket_api.async_register_command(config_entry_disable) websocket_api.async_register_command(hass, config_entry_disable)
hass.components.websocket_api.async_register_command(config_entry_update) websocket_api.async_register_command(hass, config_entry_update)
hass.components.websocket_api.async_register_command(config_entries_progress) websocket_api.async_register_command(hass, config_entries_progress)
hass.components.websocket_api.async_register_command(ignore_config_flow) websocket_api.async_register_command(hass, ignore_config_flow)
return True return True

View File

@ -33,11 +33,11 @@ SCHEMA_WS_UPDATE = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend(
async def async_setup(hass): async def async_setup(hass):
"""Enable the Device Registry views.""" """Enable the Device Registry views."""
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_LIST, websocket_list_devices, SCHEMA_WS_LIST hass, WS_TYPE_LIST, websocket_list_devices, SCHEMA_WS_LIST
) )
hass.components.websocket_api.async_register_command( websocket_api.async_register_command(
WS_TYPE_UPDATE, websocket_update_device, SCHEMA_WS_UPDATE hass, WS_TYPE_UPDATE, websocket_update_device, SCHEMA_WS_UPDATE
) )
return True return True