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

Functions

set[str] _async_config_entries_for_ids (HomeAssistant hass, list[str]|None entity_ids, list[str]|None device_ids)
 
bool _is_state_filtered (State new_state, State old_state)
 
tuple[EventType[Any]|str,...] async_determine_event_types (HomeAssistant hass, list[str]|None entity_ids, list[str]|None device_ids)
 
list[str] async_filter_entities (HomeAssistant hass, list[str] entity_ids)
 
None async_subscribe_events (HomeAssistant hass, list[CALLBACK_TYPE] subscriptions, Callable[[Event[Any]], None] target, tuple[EventType[Any]|str,...] event_types, Callable[[str], bool]|None entities_filter, list[str]|None entity_ids, list[str]|None device_ids)
 
Callable[[Event], None] event_forwarder_filtered (Callable[[Event], None] target, Callable[[str], bool]|None entities_filter, list[str]|None entity_ids, list[str]|None device_ids)
 
list[str] extract_attr (Mapping[str, Any] source, str attr)
 
bool is_sensor_continuous (HomeAssistant hass, er.EntityRegistry ent_reg, str entity_id)
 

Detailed Description

Event parser and human readable log generator.

Function Documentation

◆ _async_config_entries_for_ids()

set[str] homeassistant.components.logbook.helpers._async_config_entries_for_ids ( HomeAssistant  hass,
list[str] | None  entity_ids,
list[str] | None   device_ids 
)
private
Find the config entry ids for a set of entities or devices.

Definition at line 47 of file helpers.py.

◆ _is_state_filtered()

bool homeassistant.components.logbook.helpers._is_state_filtered ( State  new_state,
State  old_state 
)
private
Check if the logbook should filter a state.

Used when we are in live mode to ensure
we only get significant changes (state.last_changed != state.last_updated)

Definition at line 251 of file helpers.py.

◆ async_determine_event_types()

tuple[EventType[Any] | str, ...] homeassistant.components.logbook.helpers.async_determine_event_types ( HomeAssistant  hass,
list[str] | None  entity_ids,
list[str] | None   device_ids 
)
Reduce the event types based on the entity ids and device ids.

Definition at line 65 of file helpers.py.

◆ async_filter_entities()

list[str] homeassistant.components.logbook.helpers.async_filter_entities ( HomeAssistant  hass,
list[str]  entity_ids 
)
Filter out any entities that logbook will not produce results for.

Definition at line 35 of file helpers.py.

◆ async_subscribe_events()

None homeassistant.components.logbook.helpers.async_subscribe_events ( HomeAssistant  hass,
list[CALLBACK_TYPE]  subscriptions,
Callable[[Event[Any]], None]  target,
tuple[EventType[Any] | str, ...]  event_types,
Callable[[str], bool] | None  entities_filter,
list[str] | None  entity_ids,
list[str] | None  device_ids 
)
Subscribe to events for the entities and devices or all.

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

Definition at line 160 of file helpers.py.

◆ event_forwarder_filtered()

Callable[[Event], None] homeassistant.components.logbook.helpers.event_forwarder_filtered ( Callable[[Event], None]  target,
Callable[[str], bool] | None  entities_filter,
list[str] | None  entity_ids,
list[str] | None  device_ids 
)
Make a callable to filter events.

Definition at line 108 of file helpers.py.

◆ extract_attr()

list[str] homeassistant.components.logbook.helpers.extract_attr ( Mapping[str, Any]  source,
str  attr 
)
Extract an attribute as a list or string.

Definition at line 98 of file helpers.py.

◆ is_sensor_continuous()

bool homeassistant.components.logbook.helpers.is_sensor_continuous ( HomeAssistant  hass,
er.EntityRegistry  ent_reg,
str   entity_id 
)
Determine if a sensor is continuous.

Sensors with a unit_of_measurement or state_class are considered continuous.

The unit_of_measurement check will already happen if this is
called for historical data because the SQL query generated by _get_events
will filter out any sensors with a unit_of_measurement.

If the state still exists in the state machine, this function still
checks for ATTR_UNIT_OF_MEASUREMENT since the live mode is not filtered
by the SQL query.

Definition at line 217 of file helpers.py.