Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.entityfilter Namespace Reference

Classes

class  EntityFilter
 

Functions

re.Pattern[str]|None _convert_globs_to_pattern (list[str]|None globs)
 
Callable[[str], bool] _generate_filter_from_sets_and_pattern_lists (set[str] include_d, set[str] include_e, set[str] exclude_d, set[str] exclude_e, re.Pattern[str]|None include_eg, re.Pattern[str]|None exclude_eg)
 
EntityFilter convert_filter (dict[str, list[str]] config)
 
EntityFilter convert_include_exclude_filter (dict[str, dict[str, list[str]]] config)
 
Callable[[str], bool] generate_filter (list[str] include_domains, list[str] include_entities, list[str] exclude_domains, list[str] exclude_entities, list[str]|None include_entity_globs=None, list[str]|None exclude_entity_globs=None)
 

Variables

 BASE_FILTER_SCHEMA
 
string CONF_ENTITY_GLOBS = "entity_globs"
 
string CONF_EXCLUDE_DOMAINS = "exclude_domains"
 
string CONF_EXCLUDE_ENTITIES = "exclude_entities"
 
string CONF_EXCLUDE_ENTITY_GLOBS = "exclude_entity_globs"
 
string CONF_INCLUDE_DOMAINS = "include_domains"
 
string CONF_INCLUDE_ENTITIES = "include_entities"
 
string CONF_INCLUDE_ENTITY_GLOBS = "include_entity_globs"
 
 FILTER_SCHEMA = vol.All(BASE_FILTER_SCHEMA, convert_filter)
 
 INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA
 
 INCLUDE_EXCLUDE_FILTER_SCHEMA
 
 INCLUDE_EXCLUDE_FILTER_SCHEMA_INNER
 

Detailed Description

Helper class to implement include/exclude of entities and domains.

Function Documentation

◆ _convert_globs_to_pattern()

re.Pattern[str] | None homeassistant.helpers.entityfilter._convert_globs_to_pattern ( list[str] | None  globs)
private
Convert a list of globs to a re pattern list.

Definition at line 148 of file entityfilter.py.

◆ _generate_filter_from_sets_and_pattern_lists()

Callable[[str], bool] homeassistant.helpers.entityfilter._generate_filter_from_sets_and_pattern_lists ( set[str]  include_d,
set[str]  include_e,
set[str]  exclude_d,
set[str]  exclude_e,
re.Pattern[str] | None  include_eg,
re.Pattern[str] | None  exclude_eg 
)
private
Generate a filter from pre-comuted sets and pattern lists.

Definition at line 184 of file entityfilter.py.

◆ convert_filter()

EntityFilter homeassistant.helpers.entityfilter.convert_filter ( dict[str, list[str]]  config)
Convert the filter schema into a filter.

Definition at line 77 of file entityfilter.py.

◆ convert_include_exclude_filter()

EntityFilter homeassistant.helpers.entityfilter.convert_include_exclude_filter ( dict[str, dict[str, list[str]]]  config)
Convert the include exclude filter schema into a filter.

Definition at line 104 of file entityfilter.py.

◆ generate_filter()

Callable[[str], bool] homeassistant.helpers.entityfilter.generate_filter ( list[str]  include_domains,
list[str]  include_entities,
list[str]  exclude_domains,
list[str]  exclude_entities,
list[str] | None   include_entity_globs = None,
list[str] | None   exclude_entity_globs = None 
)
Return a function that will filter entities based on the args.

Definition at line 165 of file entityfilter.py.

Variable Documentation

◆ BASE_FILTER_SCHEMA

homeassistant.helpers.entityfilter.BASE_FILTER_SCHEMA
Initial value:
1 = vol.Schema(
2  {
3  vol.Optional(CONF_EXCLUDE_DOMAINS, default=[]): vol.All(
4  cv.ensure_list, [cv.string]
5  ),
6  vol.Optional(CONF_EXCLUDE_ENTITY_GLOBS, default=[]): vol.All(
7  cv.ensure_list, [cv.string]
8  ),
9  vol.Optional(CONF_EXCLUDE_ENTITIES, default=[]): cv.entity_ids,
10  vol.Optional(CONF_INCLUDE_DOMAINS, default=[]): vol.All(
11  cv.ensure_list, [cv.string]
12  ),
13  vol.Optional(CONF_INCLUDE_ENTITY_GLOBS, default=[]): vol.All(
14  cv.ensure_list, [cv.string]
15  ),
16  vol.Optional(CONF_INCLUDE_ENTITIES, default=[]): cv.entity_ids,
17  }
18 )

Definition at line 82 of file entityfilter.py.

◆ CONF_ENTITY_GLOBS

string homeassistant.helpers.entityfilter.CONF_ENTITY_GLOBS = "entity_globs"

Definition at line 31 of file entityfilter.py.

◆ CONF_EXCLUDE_DOMAINS

string homeassistant.helpers.entityfilter.CONF_EXCLUDE_DOMAINS = "exclude_domains"

Definition at line 27 of file entityfilter.py.

◆ CONF_EXCLUDE_ENTITIES

string homeassistant.helpers.entityfilter.CONF_EXCLUDE_ENTITIES = "exclude_entities"

Definition at line 29 of file entityfilter.py.

◆ CONF_EXCLUDE_ENTITY_GLOBS

string homeassistant.helpers.entityfilter.CONF_EXCLUDE_ENTITY_GLOBS = "exclude_entity_globs"

Definition at line 28 of file entityfilter.py.

◆ CONF_INCLUDE_DOMAINS

string homeassistant.helpers.entityfilter.CONF_INCLUDE_DOMAINS = "include_domains"

Definition at line 24 of file entityfilter.py.

◆ CONF_INCLUDE_ENTITIES

string homeassistant.helpers.entityfilter.CONF_INCLUDE_ENTITIES = "include_entities"

Definition at line 26 of file entityfilter.py.

◆ CONF_INCLUDE_ENTITY_GLOBS

string homeassistant.helpers.entityfilter.CONF_INCLUDE_ENTITY_GLOBS = "include_entity_globs"

Definition at line 25 of file entityfilter.py.

◆ FILTER_SCHEMA

homeassistant.helpers.entityfilter.FILTER_SCHEMA = vol.All(BASE_FILTER_SCHEMA, convert_filter)

Definition at line 101 of file entityfilter.py.

◆ INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA

homeassistant.helpers.entityfilter.INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA
Initial value:
1 = vol.Schema(
2  {
3  vol.Optional(
4  CONF_INCLUDE, default=INCLUDE_EXCLUDE_FILTER_SCHEMA_INNER({})
5  ): INCLUDE_EXCLUDE_FILTER_SCHEMA_INNER,
6  vol.Optional(
7  CONF_EXCLUDE, default=INCLUDE_EXCLUDE_FILTER_SCHEMA_INNER({})
8  ): INCLUDE_EXCLUDE_FILTER_SCHEMA_INNER,
9  }
10 )

Definition at line 132 of file entityfilter.py.

◆ INCLUDE_EXCLUDE_FILTER_SCHEMA

homeassistant.helpers.entityfilter.INCLUDE_EXCLUDE_FILTER_SCHEMA
Initial value:
1 = vol.All(
2  INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA, convert_include_exclude_filter
3 )

Definition at line 143 of file entityfilter.py.

◆ INCLUDE_EXCLUDE_FILTER_SCHEMA_INNER

homeassistant.helpers.entityfilter.INCLUDE_EXCLUDE_FILTER_SCHEMA_INNER
Initial value:
1 = vol.Schema(
2  {
3  vol.Optional(CONF_DOMAINS, default=[]): vol.All(cv.ensure_list, [cv.string]),
4  vol.Optional(CONF_ENTITY_GLOBS, default=[]): vol.All(
5  cv.ensure_list, [cv.string]
6  ),
7  vol.Optional(CONF_ENTITIES, default=[]): cv.entity_ids,
8  }
9 )

Definition at line 122 of file entityfilter.py.