1
mirror of https://github.com/home-assistant/core synced 2024-07-12 07:21:24 +02:00

Import websocket_api (part 2) (#63906)

This commit is contained in:
Erik Montnemery 2022-01-11 17:26:25 +01:00 committed by GitHub
parent aab5a097a0
commit 3b7448bb1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 47 deletions

View File

@ -18,10 +18,10 @@ from homeassistant.helpers.entity_registry import (
async def async_setup(hass):
"""Enable the Entity Registry views."""
hass.components.websocket_api.async_register_command(websocket_list_entities)
hass.components.websocket_api.async_register_command(websocket_get_entity)
hass.components.websocket_api.async_register_command(websocket_update_entity)
hass.components.websocket_api.async_register_command(websocket_remove_entity)
websocket_api.async_register_command(hass, websocket_list_entities)
websocket_api.async_register_command(hass, websocket_get_entity)
websocket_api.async_register_command(hass, websocket_update_entity)
websocket_api.async_register_command(hass, websocket_remove_entity)
return True

View File

@ -73,9 +73,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
DOMAIN, SERVICE_PROCESS, handle_service, schema=SERVICE_PROCESS_SCHEMA
)
hass.http.register_view(ConversationProcessView())
hass.components.websocket_api.async_register_command(websocket_process)
hass.components.websocket_api.async_register_command(websocket_get_agent_info)
hass.components.websocket_api.async_register_command(websocket_set_onboarding)
websocket_api.async_register_command(hass, websocket_process)
websocket_api.async_register_command(hass, websocket_get_agent_info)
websocket_api.async_register_command(hass, websocket_set_onboarding)
return True

View File

@ -96,23 +96,21 @@ async def async_get_device_automations(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up device automation."""
hass.components.websocket_api.async_register_command(
websocket_device_automation_list_actions
websocket_api.async_register_command(hass, websocket_device_automation_list_actions)
websocket_api.async_register_command(
hass, websocket_device_automation_list_conditions
)
hass.components.websocket_api.async_register_command(
websocket_device_automation_list_conditions
websocket_api.async_register_command(
hass, websocket_device_automation_list_triggers
)
hass.components.websocket_api.async_register_command(
websocket_device_automation_list_triggers
websocket_api.async_register_command(
hass, websocket_device_automation_get_action_capabilities
)
hass.components.websocket_api.async_register_command(
websocket_device_automation_get_action_capabilities
websocket_api.async_register_command(
hass, websocket_device_automation_get_condition_capabilities
)
hass.components.websocket_api.async_register_command(
websocket_device_automation_get_condition_capabilities
)
hass.components.websocket_api.async_register_command(
websocket_device_automation_get_trigger_capabilities
websocket_api.async_register_command(
hass, websocket_device_automation_get_trigger_capabilities
)
return True

View File

@ -326,10 +326,10 @@ def _frontend_root(dev_repo_path: str | None) -> pathlib.Path:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the serving of the frontend."""
await async_setup_frontend_storage(hass)
hass.components.websocket_api.async_register_command(websocket_get_panels)
hass.components.websocket_api.async_register_command(websocket_get_themes)
hass.components.websocket_api.async_register_command(websocket_get_translations)
hass.components.websocket_api.async_register_command(websocket_get_version)
websocket_api.async_register_command(hass, websocket_get_panels)
websocket_api.async_register_command(hass, websocket_get_themes)
websocket_api.async_register_command(hass, websocket_get_translations)
websocket_api.async_register_command(hass, websocket_get_version)
hass.http.register_view(ManifestJSONView())
conf = config.get(DOMAIN, {})

View File

@ -19,8 +19,8 @@ STORAGE_VERSION_USER_DATA = 1
async def async_setup_frontend_storage(hass: HomeAssistant) -> None:
"""Set up frontend storage."""
hass.data[DATA_STORAGE] = ({}, {})
hass.components.websocket_api.async_register_command(websocket_set_user_data)
hass.components.websocket_api.async_register_command(websocket_get_user_data)
websocket_api.async_register_command(hass, websocket_set_user_data)
websocket_api.async_register_command(hass, websocket_get_user_data)
def with_store(orig_func: Callable) -> Callable:

View File

@ -101,10 +101,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.components.frontend.async_register_built_in_panel(
"history", "history", "hass:chart-box"
)
hass.components.websocket_api.async_register_command(
ws_get_statistics_during_period
)
hass.components.websocket_api.async_register_command(ws_get_list_statistic_ids)
websocket_api.async_register_command(hass, ws_get_statistics_during_period)
websocket_api.async_register_command(hass, ws_get_list_statistic_ids)
return True

View File

@ -179,8 +179,8 @@ def get_service(hass, config, discovery_info=None):
def websocket_appkey(hass, connection, msg):
connection.send_message(websocket_api.result_message(msg["id"], vapid_pub_key))
hass.components.websocket_api.async_register_command(
WS_TYPE_APPKEY, websocket_appkey, SCHEMA_WS_APPKEY
websocket_api.async_register_command(
hass, WS_TYPE_APPKEY, websocket_appkey, SCHEMA_WS_APPKEY
)
hass.http.register_view(HTML5PushRegistrationView(registrations, json_path))

View File

@ -3,7 +3,7 @@ import logging
import voluptuous as vol
from homeassistant.components import frontend
from homeassistant.components import frontend, websocket_api
from homeassistant.config import async_hass_config_yaml, async_process_component_config
from homeassistant.const import CONF_FILENAME, CONF_MODE, CONF_RESOURCES
from homeassistant.core import HomeAssistant, ServiceCall, callback
@ -121,22 +121,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
RESOURCE_UPDATE_FIELDS,
).async_setup(hass, create_list=False)
hass.components.websocket_api.async_register_command(
websocket.websocket_lovelace_config
)
hass.components.websocket_api.async_register_command(
websocket.websocket_lovelace_save_config
)
hass.components.websocket_api.async_register_command(
websocket.websocket_lovelace_delete_config
)
hass.components.websocket_api.async_register_command(
websocket.websocket_lovelace_resources
websocket_api.async_register_command(hass, websocket.websocket_lovelace_config)
websocket_api.async_register_command(hass, websocket.websocket_lovelace_save_config)
websocket_api.async_register_command(
hass, websocket.websocket_lovelace_delete_config
)
websocket_api.async_register_command(hass, websocket.websocket_lovelace_resources)
hass.components.websocket_api.async_register_command(
websocket.websocket_lovelace_dashboards
)
websocket_api.async_register_command(hass, websocket.websocket_lovelace_dashboards)
hass.data[DOMAIN] = {
# We store a dictionary mapping url_path: config. None is the default.