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

Classes

class  ABCCachedProperties
 
class  CachedProperties
 
class  CalculatedState
 
class  Entity
 
class  EntityDescription
 
class  EntityInfo
 
class  EntityPlatformState
 
class  StateInfo
 
class  ToggleEntity
 
class  ToggleEntityDescription
 

Functions

str async_generate_entity_id (str entity_id_format, str|None name, Iterable[str]|None current_ids=None, HomeAssistant|None hass=None)
 
None async_setup (HomeAssistant hass)
 
dict[str, EntityInfoentity_sources (HomeAssistant hass)
 
str generate_entity_id (str entity_id_format, str|None name, list[str]|None current_ids=None, HomeAssistant|None hass=None)
 
Any|None get_capability (HomeAssistant hass, str entity_id, str capability)
 
str|None get_device_class (HomeAssistant hass, str entity_id)
 
int get_supported_features (HomeAssistant hass, str entity_id)
 
str|None get_unit_of_measurement (HomeAssistant hass, str entity_id)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
 _SENTINEL = object()
 
dictionary CACHED_PROPERTIES_WITH_ATTR_
 
int CAPABILITIES_UPDATE_LIMIT = 100
 
int CONTEXT_RECENT_TIME_SECONDS = 5
 
string DATA_ENTITY_SOURCE = "entity_info"
 
int FLOAT_PRECISION = abs(int(math.floor(math.log10(abs(sys.float_info.epsilon))))) - 1
 
int SLOW_UPDATE_WARNING = 10
 
 timer = time.time
 
dictionary TOGGLE_ENTITY_CACHED_PROPERTIES_WITH_ATTR_ = {"is_on"}
 

Detailed Description

An abstract class for entities.

Function Documentation

◆ async_generate_entity_id()

str homeassistant.helpers.entity.async_generate_entity_id ( str  entity_id_format,
str | None  name,
Iterable[str] | None   current_ids = None,
HomeAssistant | None   hass = None 
)
Generate a unique entity ID based on given entity IDs or used IDs.

Definition at line 114 of file entity.py.

◆ async_setup()

None homeassistant.helpers.entity.async_setup ( HomeAssistant  hass)
Set up entity sources.

Definition at line 90 of file entity.py.

◆ entity_sources()

dict[str, EntityInfo] homeassistant.helpers.entity.entity_sources ( HomeAssistant  hass)
Get the entity sources.

Definition at line 98 of file entity.py.

◆ generate_entity_id()

str homeassistant.helpers.entity.generate_entity_id ( str  entity_id_format,
str | None  name,
list[str] | None   current_ids = None,
HomeAssistant | None   hass = None 
)
Generate a unique entity ID based on given entity IDs or used IDs.

Definition at line 103 of file entity.py.

◆ get_capability()

Any | None homeassistant.helpers.entity.get_capability ( HomeAssistant  hass,
str  entity_id,
str  capability 
)
Get a capability attribute of an entity.

First try the statemachine, then entity registry.

Definition at line 139 of file entity.py.

◆ get_device_class()

str | None homeassistant.helpers.entity.get_device_class ( HomeAssistant  hass,
str  entity_id 
)
Get device class of an entity.

First try the statemachine, then entity registry.

Definition at line 154 of file entity.py.

◆ get_supported_features()

int homeassistant.helpers.entity.get_supported_features ( HomeAssistant  hass,
str  entity_id 
)
Get supported features for an entity.

First try the statemachine, then entity registry.

Definition at line 169 of file entity.py.

◆ get_unit_of_measurement()

str | None homeassistant.helpers.entity.get_unit_of_measurement ( HomeAssistant  hass,
str  entity_id 
)
Get unit of measurement of an entity.

First try the statemachine, then entity registry.

Definition at line 184 of file entity.py.

Variable Documentation

◆ _LOGGER

homeassistant.helpers.entity._LOGGER = logging.getLogger(__name__)
private

Definition at line 75 of file entity.py.

◆ _SENTINEL

homeassistant.helpers.entity._SENTINEL = object()
private

Definition at line 232 of file entity.py.

◆ CACHED_PROPERTIES_WITH_ATTR_

dictionary homeassistant.helpers.entity.CACHED_PROPERTIES_WITH_ATTR_
Initial value:
1 = {
2  "assumed_state",
3  "attribution",
4  "available",
5  "capability_attributes",
6  "device_class",
7  "device_info",
8  "entity_category",
9  "has_entity_name",
10  "entity_picture",
11  "entity_registry_enabled_default",
12  "entity_registry_visible_default",
13  "extra_state_attributes",
14  "force_update",
15  "icon",
16  "name",
17  "should_poll",
18  "state",
19  "supported_features",
20  "translation_key",
21  "translation_placeholders",
22  "unique_id",
23  "unit_of_measurement",
24 }

Definition at line 405 of file entity.py.

◆ CAPABILITIES_UPDATE_LIMIT

int homeassistant.helpers.entity.CAPABILITIES_UPDATE_LIMIT = 100

Definition at line 84 of file entity.py.

◆ CONTEXT_RECENT_TIME_SECONDS

int homeassistant.helpers.entity.CONTEXT_RECENT_TIME_SECONDS = 5

Definition at line 86 of file entity.py.

◆ DATA_ENTITY_SOURCE

string homeassistant.helpers.entity.DATA_ENTITY_SOURCE = "entity_info"

Definition at line 77 of file entity.py.

◆ FLOAT_PRECISION

int homeassistant.helpers.entity.FLOAT_PRECISION = abs(int(math.floor(math.log10(abs(sys.float_info.epsilon))))) - 1

Definition at line 81 of file entity.py.

◆ SLOW_UPDATE_WARNING

int homeassistant.helpers.entity.SLOW_UPDATE_WARNING = 10

Definition at line 76 of file entity.py.

◆ timer

homeassistant.helpers.entity.timer = time.time

Definition at line 70 of file entity.py.

◆ TOGGLE_ENTITY_CACHED_PROPERTIES_WITH_ATTR_

dictionary homeassistant.helpers.entity.TOGGLE_ENTITY_CACHED_PROPERTIES_WITH_ATTR_ = {"is_on"}

Definition at line 1672 of file entity.py.