Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.logbook.websocket_api Namespace Reference

Classes

class  LogbookLiveStream
 

Functions

None _async_events_consumer (dt subscriptions_setup_complete_time, ActiveConnection connection, int msg_id, asyncio.Queue[Event] stream_queue, EventProcessor event_processor)
 
tuple[bytes, dt|None] _async_get_ws_stream_events (HomeAssistant hass, int msg_id, dt start_time, dt end_time, EventProcessor event_processor, bool partial)
 
None _async_send_empty_response (ActiveConnection connection, int msg_id, dt start_time, dt|None end_time)
 
dt|None _async_send_historical_events (HomeAssistant hass, ActiveConnection connection, int msg_id, dt start_time, dt end_time, EventProcessor event_processor, bool partial, bool force_send=False)
 
dict[str, Any] _generate_stream_message (list[dict[str, Any]] events, dt start_day, dt end_day)
 
bytes _ws_formatted_get_events (int msg_id, dt start_time, dt end_time, EventProcessor event_processor)
 
tuple[bytes, dt|None] _ws_stream_get_events (int msg_id, dt start_day, dt end_day, EventProcessor event_processor, bool partial)
 
None async_setup (HomeAssistant hass)
 
None ws_event_stream (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_get_events (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
int BIG_QUERY_HOURS = 25
 
int BIG_QUERY_RECENT_HOURS = 24
 
float EVENT_COALESCE_TIME = 0.35
 
int MAX_PENDING_LOGBOOK_EVENTS = 2048
 

Detailed Description

Event parser and human readable log generator.

Function Documentation

◆ _async_events_consumer()

None homeassistant.components.logbook.websocket_api._async_events_consumer ( dt  subscriptions_setup_complete_time,
ActiveConnection  connection,
int  msg_id,
asyncio.Queue[Event stream_queue,
EventProcessor  event_processor 
)
private
Stream events from the queue.

Definition at line 209 of file websocket_api.py.

◆ _async_get_ws_stream_events()

tuple[bytes, dt | None] homeassistant.components.logbook.websocket_api._async_get_ws_stream_events ( HomeAssistant  hass,
int  msg_id,
dt  start_time,
dt  end_time,
EventProcessor  event_processor,
bool  partial 
)
private
Async wrapper around _ws_formatted_get_events.

Definition at line 157 of file websocket_api.py.

◆ _async_send_empty_response()

None homeassistant.components.logbook.websocket_api._async_send_empty_response ( ActiveConnection  connection,
int  msg_id,
dt  start_time,
dt | None   end_time 
)
private
Send an empty response.

The current case for this is when they ask for entity_ids
that will all be filtered away because they have UOMs or
state_class.

Definition at line 61 of file websocket_api.py.

◆ _async_send_historical_events()

dt | None homeassistant.components.logbook.websocket_api._async_send_historical_events ( HomeAssistant  hass,
ActiveConnection  connection,
int  msg_id,
dt  start_time,
dt  end_time,
EventProcessor  event_processor,
bool  partial,
bool   force_send = False 
)
private
Select historical data from the database and deliver it to the websocket.

If the query is considered a big query we will split the request into
two chunks so that they get the recent events first and the select
that is expected to take a long time comes in after to ensure
they are not stuck at a loading screen and can start looking at
the data right away.

This function returns the time of the most recent event we sent to the
websocket.

Definition at line 77 of file websocket_api.py.

◆ _generate_stream_message()

dict[str, Any] homeassistant.components.logbook.websocket_api._generate_stream_message ( list[dict[str, Any]]  events,
dt  start_day,
dt   end_day 
)
private
Generate a logbook stream message response.

Definition at line 176 of file websocket_api.py.

◆ _ws_formatted_get_events()

bytes homeassistant.components.logbook.websocket_api._ws_formatted_get_events ( int  msg_id,
dt  start_time,
dt  end_time,
EventProcessor  event_processor 
)
private
Fetch events and convert them to json in the executor.

Definition at line 430 of file websocket_api.py.

◆ _ws_stream_get_events()

tuple[bytes, dt | None] homeassistant.components.logbook.websocket_api._ws_stream_get_events ( int  msg_id,
dt  start_day,
dt  end_day,
EventProcessor  event_processor,
bool  partial 
)
private
Fetch events and convert them to json in the executor.

Definition at line 187 of file websocket_api.py.

◆ async_setup()

None homeassistant.components.logbook.websocket_api.async_setup ( HomeAssistant  hass)
Set up the logbook websocket API.

Definition at line 54 of file websocket_api.py.

◆ ws_event_stream()

None homeassistant.components.logbook.websocket_api.ws_event_stream ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle logbook stream events websocket command.

Definition at line 257 of file websocket_api.py.

◆ ws_get_events()

None homeassistant.components.logbook.websocket_api.ws_get_events ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle logbook get events websocket command.

Definition at line 455 of file websocket_api.py.

Variable Documentation

◆ _LOGGER

homeassistant.components.logbook.websocket_api._LOGGER = logging.getLogger(__name__)
private

Definition at line 39 of file websocket_api.py.

◆ BIG_QUERY_HOURS

int homeassistant.components.logbook.websocket_api.BIG_QUERY_HOURS = 25

Definition at line 35 of file websocket_api.py.

◆ BIG_QUERY_RECENT_HOURS

int homeassistant.components.logbook.websocket_api.BIG_QUERY_RECENT_HOURS = 24

Definition at line 37 of file websocket_api.py.

◆ EVENT_COALESCE_TIME

float homeassistant.components.logbook.websocket_api.EVENT_COALESCE_TIME = 0.35

Definition at line 33 of file websocket_api.py.

◆ MAX_PENDING_LOGBOOK_EVENTS

int homeassistant.components.logbook.websocket_api.MAX_PENDING_LOGBOOK_EVENTS = 2048

Definition at line 32 of file websocket_api.py.