Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.sql.sensor Namespace Reference

Classes

class  SQLSensor
 

Functions

SQLData _async_get_or_init_domain_data (HomeAssistant hass)
 
StatementLambdaElement _generate_lambda_stmt (str query)
 
scoped_session|None _validate_and_get_session_maker_for_db_url (str db_url)
 
None async_setup_entry (HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
 
None async_setup_platform (HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
 
None async_setup_sensor (HomeAssistant hass, ConfigType trigger_entity_config, str query_str, str column_name, Template|None value_template, str|None unique_id, str db_url, bool yaml, AddEntitiesCallback async_add_entities)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
 LRUCache
 
tuple TRIGGER_ENTITY_OPTIONS
 

Detailed Description

Sensor from an SQL Query.

Function Documentation

◆ _async_get_or_init_domain_data()

SQLData homeassistant.components.sql.sensor._async_get_or_init_domain_data ( HomeAssistant  hass)
private
Get or initialize domain data.

Definition at line 143 of file sensor.py.

◆ _generate_lambda_stmt()

StatementLambdaElement homeassistant.components.sql.sensor._generate_lambda_stmt ( str  query)
private
Generate the lambda statement.

Definition at line 297 of file sensor.py.

◆ _validate_and_get_session_maker_for_db_url()

scoped_session | None homeassistant.components.sql.sensor._validate_and_get_session_maker_for_db_url ( str  db_url)
private
Validate the db_url and return a session maker.

This does I/O and should be run in the executor.

Definition at line 270 of file sensor.py.

◆ async_setup_entry()

None homeassistant.components.sql.sensor.async_setup_entry ( HomeAssistant  hass,
ConfigEntry  entry,
AddEntitiesCallback   async_add_entities 
)
Set up the SQL sensor from config entry.

Definition at line 103 of file sensor.py.

◆ async_setup_platform()

None homeassistant.components.sql.sensor.async_setup_platform ( HomeAssistant  hass,
ConfigType  config,
AddEntitiesCallback  async_add_entities,
DiscoveryInfoType | None   discovery_info = None 
)
Set up the SQL sensor from yaml.

Definition at line 67 of file sensor.py.

◆ async_setup_sensor()

None homeassistant.components.sql.sensor.async_setup_sensor ( HomeAssistant  hass,
ConfigType  trigger_entity_config,
str  query_str,
str  column_name,
Template | None  value_template,
str | None  unique_id,
str  db_url,
bool  yaml,
AddEntitiesCallback  async_add_entities 
)
Set up the SQL sensor.

Definition at line 172 of file sensor.py.

Variable Documentation

◆ _LOGGER

homeassistant.components.sql.sensor._LOGGER = logging.getLogger(__name__)
private

Definition at line 52 of file sensor.py.

◆ LRUCache

homeassistant.components.sql.sensor.LRUCache

Definition at line 54 of file sensor.py.

◆ TRIGGER_ENTITY_OPTIONS

tuple homeassistant.components.sql.sensor.TRIGGER_ENTITY_OPTIONS
Initial value:
1 = (
2  CONF_AVAILABILITY,
3  CONF_DEVICE_CLASS,
4  CONF_ICON,
5  CONF_PICTURE,
6  CONF_UNIQUE_ID,
7  CONF_STATE_CLASS,
8  CONF_UNIT_OF_MEASUREMENT,
9 )

Definition at line 56 of file sensor.py.