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

Classes

class  HistoryLiveStream
 

Functions

None _async_events_consumer (dt subscriptions_setup_complete_time, ActiveConnection connection, int msg_id, asyncio.Queue[Event] stream_queue, bool no_attributes)
 
None _async_send_empty_response (ActiveConnection connection, int msg_id, dt start_time, dt|None end_time)
 
dt|None _async_send_historical_states (HomeAssistant hass, ActiveConnection connection, int msg_id, dt start_time, dt end_time, list[str]|None entity_ids, bool include_start_time_state, bool significant_changes_only, bool minimal_response, bool no_attributes, bool send_empty)
 
None _async_subscribe_events (HomeAssistant hass, list[CALLBACK_TYPE] subscriptions, Callable[[Event[Any]], None] target, list[str] entity_ids, bool significant_changes_only, bool minimal_response)
 
dict[str, list[dict[str, Any]]] _events_to_compressed_states (Iterable[Event] events, bool no_attributes)
 
tuple[float, dt|None, bytes|None] _generate_historical_response (HomeAssistant hass, int msg_id, dt start_time, dt end_time, list[str]|None entity_ids, bool include_start_time_state, bool significant_changes_only, bool minimal_response, bool no_attributes, bool send_empty)
 
dict[str, Any] _generate_stream_message (dict[str, list[dict[str, Any]]] states, dt start_day, dt end_day)
 
bytes _generate_websocket_response (int msg_id, dt start_time, dt end_time, dict[str, list[dict[str, Any]]] states)
 
dict[str, Any] _history_compressed_state (State state, bool no_attributes)
 
bytes _ws_get_significant_states (HomeAssistant hass, int msg_id, dt start_time, dt|None end_time, list[str]|None entity_ids, bool include_start_time_state, bool significant_changes_only, bool minimal_response, bool no_attributes)
 
None async_setup (HomeAssistant hass)
 
None ws_get_history_during_period (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_stream (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 

Detailed Description

Websocket API for the history integration.

Function Documentation

◆ _async_events_consumer()

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

Definition at line 328 of file websocket_api.py.

◆ _async_send_empty_response()

None homeassistant.components.history.websocket_api._async_send_empty_response ( ActiveConnection  connection,
int  msg_id,
dt  start_time,
dt | None   end_time 
)
private
Send an empty response when we know all results are filtered away.

Definition at line 191 of file websocket_api.py.

◆ _async_send_historical_states()

dt | None homeassistant.components.history.websocket_api._async_send_historical_states ( HomeAssistant  hass,
ActiveConnection  connection,
int  msg_id,
dt  start_time,
dt  end_time,
list[str] | None  entity_ids,
bool  include_start_time_state,
bool  significant_changes_only,
bool  minimal_response,
bool  no_attributes,
bool  send_empty 
)
private
Fetch history significant_states and send them to the client.

Definition at line 270 of file websocket_api.py.

◆ _async_subscribe_events()

None homeassistant.components.history.websocket_api._async_subscribe_events ( HomeAssistant  hass,
list[CALLBACK_TYPE]  subscriptions,
Callable[[Event[Any]], None]  target,
list[str]  entity_ids,
bool  significant_changes_only,
bool  minimal_response 
)
private
Subscribe to events for the entities and devices or all.

These are the events we need to listen for to do
the live history stream.

Definition at line 365 of file websocket_api.py.

◆ _events_to_compressed_states()

dict[str, list[dict[str, Any]]] homeassistant.components.history.websocket_api._events_to_compressed_states ( Iterable[Event events,
bool   no_attributes 
)
private
Convert events to a compressed states.

Definition at line 314 of file websocket_api.py.

◆ _generate_historical_response()

tuple[float, dt | None, bytes | None] homeassistant.components.history.websocket_api._generate_historical_response ( HomeAssistant  hass,
int  msg_id,
dt  start_time,
dt  end_time,
list[str] | None  entity_ids,
bool  include_start_time_state,
bool  significant_changes_only,
bool  minimal_response,
bool  no_attributes,
bool  send_empty 
)
private
Generate a historical response.

Definition at line 216 of file websocket_api.py.

◆ _generate_stream_message()

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

Definition at line 177 of file websocket_api.py.

◆ _generate_websocket_response()

bytes homeassistant.components.history.websocket_api._generate_websocket_response ( int  msg_id,
dt  start_time,
dt  end_time,
dict[str, list[dict[str, Any]]]  states 
)
private
Generate a websocket response.

Definition at line 202 of file websocket_api.py.

◆ _history_compressed_state()

dict[str, Any] homeassistant.components.history.websocket_api._history_compressed_state ( State  state,
bool  no_attributes 
)
private
Convert a state to a compressed state.

Definition at line 303 of file websocket_api.py.

◆ _ws_get_significant_states()

bytes homeassistant.components.history.websocket_api._ws_get_significant_states ( HomeAssistant  hass,
int  msg_id,
dt  start_time,
dt | None  end_time,
list[str] | None  entity_ids,
bool  include_start_time_state,
bool  significant_changes_only,
bool  minimal_response,
bool  no_attributes 
)
private
Fetch history significant_states and convert them to json in the executor.

Definition at line 65 of file websocket_api.py.

◆ async_setup()

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

Definition at line 59 of file websocket_api.py.

◆ ws_get_history_during_period()

None homeassistant.components.history.websocket_api.ws_get_history_during_period ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle history during period websocket command.

Definition at line 109 of file websocket_api.py.

◆ ws_stream()

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

Definition at line 413 of file websocket_api.py.

Variable Documentation

◆ _LOGGER

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

Definition at line 44 of file websocket_api.py.