1 """Websocket API handlers for the logger integration."""
5 import voluptuous
as vol
13 from .const
import LOGSEVERITY
14 from .helpers
import (
18 async_get_domain_config,
25 """Set up the websocket API."""
26 websocket_api.async_register_command(hass, handle_integration_log_info)
27 websocket_api.async_register_command(hass, handle_integration_log_level)
28 websocket_api.async_register_command(hass, handle_module_log_level)
32 @websocket_api.websocket_command({vol.Required("type"):
"logger/log_info"})
34 hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
36 """Handle integrations logger info."""
37 connection.send_result(
41 "domain": integration,
43 f
"homeassistant.components.{integration}"
44 ).getEffectiveLevel(),
51 @websocket_api.websocket_command(
{
vol.Required("type"):
"logger/integration_log_level",
52 vol.Required(
"integration"): str,
53 vol.Required(
"level"): vol.In(LOGSEVERITY),
54 vol.Required(
"persistence"): vol.Coerce(LogPersistance),
57 @websocket_api.async_response
59 hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
61 """Handle setting integration log level."""
64 except IntegrationNotFound:
65 connection.send_error(
66 msg[
"id"], websocket_api.ERR_NOT_FOUND,
"Integration not found"
74 persistence=msg[
"persistence"],
75 type=LogSettingsType.INTEGRATION,
78 connection.send_message(websocket_api.messages.result_message(msg[
"id"]))
81 @websocket_api.websocket_command(
{
vol.Required("type"):
"logger/log_level",
82 vol.Required(
"module"): str,
83 vol.Required(
"level"): vol.In(LOGSEVERITY),
84 vol.Required(
"persistence"): vol.Coerce(LogPersistance),
87 @websocket_api.async_response
89 hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
91 """Handle setting integration log level."""
97 persistence=msg[
"persistence"],
98 type=LogSettingsType.MODULE,
101 connection.send_message(websocket_api.messages.result_message(msg[
"id"]))
102
LoggerDomainConfig async_get_domain_config(HomeAssistant hass)
None handle_module_log_level(HomeAssistant hass, ActiveConnection connection, dict[str, Any] msg)
None async_load_websocket_api(HomeAssistant hass)
None handle_integration_log_level(HomeAssistant hass, ActiveConnection connection, dict[str, Any] msg)
None handle_integration_log_info(HomeAssistant hass, ActiveConnection connection, dict[str, Any] msg)
Integration async_get_integration(HomeAssistant hass, str domain)
set[str] async_get_loaded_integrations(core.HomeAssistant hass)