Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.mqtt.entity.MqttEntity Class Reference
Inheritance diagram for homeassistant.components.mqtt.entity.MqttEntity:
[legend]
Collaboration diagram for homeassistant.components.mqtt.entity.MqttEntity:
[legend]

Public Member Functions

None __init__ (self, HomeAssistant hass, ConfigType config, ConfigEntry config_entry, DiscoveryInfoType|None discovery_data)
 
bool add_subscription (self, str state_topic_config_key, Callable[[ReceiveMessage], None] msg_callback, set[str]|None tracked_attributes, bool disable_encoding=False)
 
None async_added_to_hass (self)
 
None async_publish (self, str topic, PublishPayloadType payload, int qos=0, bool retain=False, str|None encoding=DEFAULT_ENCODING)
 
None async_publish_with_config (self, str topic, PublishPayloadType payload)
 
None async_will_remove_from_hass (self)
 
None discovery_update (self, MQTTDiscoveryPayload discovery_payload)
 
None mqtt_async_added_to_hass (self)
 
- Public Member Functions inherited from homeassistant.components.mqtt.entity.MqttAttributesMixin
None __init__ (self, ConfigType config)
 
None attributes_discovery_update (self, DiscoveryInfoType config)
 
None attributes_prepare_discovery_update (self, DiscoveryInfoType config)
 
- Public Member Functions inherited from homeassistant.helpers.entity.Entity
None __init_subclass__ (cls, **Any kwargs)
 
str __repr__ (self)
 
None add_to_platform_start (self, HomeAssistant hass, EntityPlatform platform, asyncio.Semaphore|None parallel_updates)
 
bool assumed_state (self)
 
None async_device_update (self, bool warning=True)
 
None async_internal_added_to_hass (self)
 
None async_internal_will_remove_from_hass (self)
 
None async_on_remove (self, CALLBACK_TYPE func)
 
None async_registry_entry_updated (self)
 
None async_remove (self, *bool force_remove=False)
 
None async_schedule_update_ha_state (self, bool force_refresh=False)
 
None async_set_context (self, Context context)
 
None async_update_ha_state (self, bool force_refresh=False)
 
None async_write_ha_state (self)
 
str|None attribution (self)
 
dict[str, Any]|None capability_attributes (self)
 
str|None device_class (self)
 
bool enabled (self)
 
EntityCategory|None entity_category (self)
 
str|None entity_picture (self)
 
bool entity_registry_enabled_default (self)
 
bool entity_registry_visible_default (self)
 
Mapping[str, Any]|None extra_state_attributes (self)
 
bool force_update (self)
 
HassJobType get_hassjob_type (self, str function_name)
 
er.EntityOptionsType|None get_initial_entity_options (self)
 
bool has_entity_name (self)
 
str|None icon (self)
 
str|UndefinedType|None name (self)
 
None schedule_update_ha_state (self, bool force_refresh=False)
 
bool should_poll (self)
 
StateType state (self)
 
dict[str, Any]|None state_attributes (self)
 
str|None suggested_object_id (self)
 
int|None supported_features (self)
 
str|None translation_key (self)
 
Mapping[str, strtranslation_placeholders (self)
 
str|None unique_id (self)
 
str|None unit_of_measurement (self)
 
bool use_device_name (self)
 
- Public Member Functions inherited from homeassistant.helpers.entity.CachedProperties
None __init__ (cls, str name, tuple[type,...] bases, dict[Any, Any] namespace, **Any kwargs)
 
Any __new__ (mcs, str name, tuple[type,...] bases, dict[Any, Any] namespace, set[str]|None cached_properties=None, **Any kwargs)
 
- Public Member Functions inherited from homeassistant.components.mqtt.entity.MqttAvailabilityMixin
None __init__ (self, ConfigType config)
 
None async_mqtt_connection_state_changed (self, bool state)
 
None availability_discovery_update (self, DiscoveryInfoType config)
 
None availability_prepare_discovery_update (self, DiscoveryInfoType config)
 
bool available (self)
 
- Public Member Functions inherited from homeassistant.components.mqtt.entity.MqttDiscoveryUpdateMixin
None __init__ (self, HomeAssistant hass, DiscoveryInfoType|None discovery_data, Callable[[MQTTDiscoveryPayload], Coroutine[Any, Any, None]]|None discovery_update=None)
 
None add_to_platform_abort (self)
 
None add_to_platform_finish (self)
 
None async_removed_from_registry (self)
 
- Public Member Functions inherited from homeassistant.components.mqtt.entity.MqttEntityDeviceInfo
None __init__ (self, dict[str, Any]|None specifications, ConfigEntry config_entry)
 
DeviceInfo|None device_info (self)
 
None device_info_discovery_update (self, DiscoveryInfoType config)
 

Static Public Member Functions

VolSchemaType config_schema ()
 

Public Attributes

 hass
 
- Public Attributes inherited from homeassistant.helpers.entity.Entity
 device_entry
 
 entity_id
 
 hass
 
 parallel_updates
 
 platform
 
 registry_entry
 

Private Member Functions

bool _attrs_have_changed (self, tuple[tuple[str, Any|UndefinedType],...] attrs_snapshot)
 
None _init_entity_id (self)
 
None _message_callback (self, MessageCallbackType msg_callback, set[str]|None attributes, ReceiveMessage msg)
 
None _prepare_subscribe_topics (self)
 
None _set_entity_name (self, ConfigType config)
 
None _setup_common_attributes_from_config (self, ConfigType config)
 
None _setup_from_config (self, ConfigType config)
 
None _subscribe_topics (self)
 

Private Attributes

 _attr_entity_category
 
 _attr_entity_picture
 
 _attr_entity_registry_enabled_default
 
 _attr_icon
 
 _attr_name
 
 _attr_unique_id
 
 _config
 
 _discovery
 
 _sub_state
 
 _subscriptions
 

Static Private Attributes

bool _attr_force_update = False
 
bool _attr_has_entity_name = True
 
bool _attr_should_poll = False
 

Additional Inherited Members

- Static Public Attributes inherited from homeassistant.components.mqtt.entity.MqttAttributesMixin
 None
 
- Static Public Attributes inherited from homeassistant.helpers.entity.Entity
 bool
 
 EntityPlatform
 
 HomeAssistant
 
 None
 
 StateInfo
 
 StateType
 
 str
 

Detailed Description

Representation of an MQTT entity.

Definition at line 1244 of file entity.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.mqtt.entity.MqttEntity.__init__ (   self,
HomeAssistant  hass,
ConfigType  config,
ConfigEntry  config_entry,
DiscoveryInfoType | None  discovery_data 
)

Member Function Documentation

◆ _attrs_have_changed()

bool homeassistant.components.mqtt.entity.MqttEntity._attrs_have_changed (   self,
tuple[tuple[str, Any | UndefinedType], ...]   attrs_snapshot 
)
private
Return True if attributes on entity changed or if update is forced.

Definition at line 1438 of file entity.py.

◆ _init_entity_id()

None homeassistant.components.mqtt.entity.MqttEntity._init_entity_id (   self)
private
Set entity_id from object_id if defined in config.

Definition at line 1289 of file entity.py.

◆ _message_callback()

None homeassistant.components.mqtt.entity.MqttEntity._message_callback (   self,
MessageCallbackType  msg_callback,
set[str] | None  attributes,
ReceiveMessage  msg 
)
private
Process the message callback.

Definition at line 1450 of file entity.py.

◆ _prepare_subscribe_topics()

None homeassistant.components.mqtt.entity.MqttEntity._prepare_subscribe_topics (   self)
private

◆ _set_entity_name()

None homeassistant.components.mqtt.entity.MqttEntity._set_entity_name (   self,
ConfigType  config 
)
private
Help setting the entity name if needed.

Definition at line 1392 of file entity.py.

◆ _setup_common_attributes_from_config()

None homeassistant.components.mqtt.entity.MqttEntity._setup_common_attributes_from_config (   self,
ConfigType  config 
)
private
(Re)Setup the common attributes for the entity.

Definition at line 1414 of file entity.py.

◆ _setup_from_config()

None homeassistant.components.mqtt.entity.MqttEntity._setup_from_config (   self,
ConfigType  config 
)
private

◆ _subscribe_topics()

◆ add_subscription()

bool homeassistant.components.mqtt.entity.MqttEntity.add_subscription (   self,
str  state_topic_config_key,
Callable[[ReceiveMessage], None msg_callback,
set[str] | None  tracked_attributes,
bool   disable_encoding = False 
)
Add a subscription.

Definition at line 1478 of file entity.py.

◆ async_added_to_hass()

None homeassistant.components.mqtt.entity.MqttEntity.async_added_to_hass (   self)
Subscribe to MQTT events.

Reimplemented from homeassistant.components.mqtt.entity.MqttAttributesMixin.

Definition at line 1296 of file entity.py.

◆ async_publish()

None homeassistant.components.mqtt.entity.MqttEntity.async_publish (   self,
str  topic,
PublishPayloadType  payload,
int   qos = 0,
bool   retain = False,
str | None   encoding = DEFAULT_ENCODING 
)
Publish message to an MQTT topic.

Definition at line 1356 of file entity.py.

◆ async_publish_with_config()

None homeassistant.components.mqtt.entity.MqttEntity.async_publish_with_config (   self,
str  topic,
PublishPayloadType   payload 
)
Publish payload to a topic using config.

Definition at line 1375 of file entity.py.

◆ async_will_remove_from_hass()

None homeassistant.components.mqtt.entity.MqttEntity.async_will_remove_from_hass (   self)
Unsubscribe when removed.

Reimplemented from homeassistant.components.mqtt.entity.MqttAttributesMixin.

Definition at line 1346 of file entity.py.

◆ config_schema()

VolSchemaType homeassistant.components.mqtt.entity.MqttEntity.config_schema ( )
static

◆ discovery_update()

None homeassistant.components.mqtt.entity.MqttEntity.discovery_update (   self,
MQTTDiscoveryPayload  discovery_payload 
)
Handle updated discovery message.

Definition at line 1316 of file entity.py.

◆ mqtt_async_added_to_hass()

None homeassistant.components.mqtt.entity.MqttEntity.mqtt_async_added_to_hass (   self)
Call before the discovery message is acknowledged.

To be extended by subclasses.

Reimplemented in homeassistant.components.mqtt.sensor.MqttSensor, and homeassistant.components.mqtt.binary_sensor.MqttBinarySensor.

Definition at line 1310 of file entity.py.

Member Data Documentation

◆ _attr_entity_category

homeassistant.components.mqtt.entity.MqttEntity._attr_entity_category
private

Definition at line 1416 of file entity.py.

◆ _attr_entity_picture

homeassistant.components.mqtt.entity.MqttEntity._attr_entity_picture
private

Definition at line 1421 of file entity.py.

◆ _attr_entity_registry_enabled_default

homeassistant.components.mqtt.entity.MqttEntity._attr_entity_registry_enabled_default
private

Definition at line 1417 of file entity.py.

◆ _attr_force_update

bool homeassistant.components.mqtt.entity.MqttEntity._attr_force_update = False
staticprivate

Definition at line 1252 of file entity.py.

◆ _attr_has_entity_name

bool homeassistant.components.mqtt.entity.MqttEntity._attr_has_entity_name = True
staticprivate

Definition at line 1253 of file entity.py.

◆ _attr_icon

homeassistant.components.mqtt.entity.MqttEntity._attr_icon
private

Definition at line 1420 of file entity.py.

◆ _attr_name

homeassistant.components.mqtt.entity.MqttEntity._attr_name
private

Definition at line 1397 of file entity.py.

◆ _attr_should_poll

bool homeassistant.components.mqtt.entity.MqttEntity._attr_should_poll = False
staticprivate

Definition at line 1254 of file entity.py.

◆ _attr_unique_id

homeassistant.components.mqtt.entity.MqttEntity._attr_unique_id
private

Definition at line 1268 of file entity.py.

◆ _config

homeassistant.components.mqtt.entity.MqttEntity._config
private

Definition at line 1323 of file entity.py.

◆ _discovery

homeassistant.components.mqtt.entity.MqttEntity._discovery
private

Definition at line 1270 of file entity.py.

◆ _sub_state

homeassistant.components.mqtt.entity.MqttEntity._sub_state
private

Definition at line 1302 of file entity.py.

◆ _subscriptions

homeassistant.components.mqtt.entity.MqttEntity._subscriptions
private

Definition at line 1299 of file entity.py.

◆ hass

homeassistant.components.mqtt.entity.MqttEntity.hass

Definition at line 1266 of file entity.py.


The documentation for this class was generated from the following file: