Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.mqtt.subscription Namespace Reference

Classes

class  EntitySubscription
 

Functions

dict[str, EntitySubscriptionasync_prepare_subscribe_topics (HomeAssistant hass, dict[str, EntitySubscription]|None sub_state, dict[str, dict[str, Any]] topics)
 
None async_subscribe_topics (HomeAssistant hass, dict[str, EntitySubscription] sub_state)
 
None async_subscribe_topics_internal (HomeAssistant hass, dict[str, EntitySubscription] sub_state)
 
dict[str, EntitySubscriptionasync_unsubscribe_topics (HomeAssistant hass, dict[str, EntitySubscription]|None sub_state)
 

Variables

 async_unsubscribe_topics = partial(async_prepare_subscribe_topics, topics={})
 

Detailed Description

Helper to handle a set of topics to subscribe to.

Function Documentation

◆ async_prepare_subscribe_topics()

dict[str, EntitySubscription] homeassistant.components.mqtt.subscription.async_prepare_subscribe_topics ( HomeAssistant  hass,
dict[str, EntitySubscription] | None  sub_state,
dict[str, dict[str, Any]]  topics 
)
Prepare (re)subscribe to a set of MQTT topics.

State is kept in sub_state and a dictionary mapping from the subscription
key to the subscription state.

After this function has been called, async_subscribe_topics must be called to
finalize any new subscriptions.

Please note that the sub state must not be shared between multiple
sets of topics. Every call to async_subscribe_topics must always
contain _all_ the topics the subscription state should manage.

Definition at line 87 of file subscription.py.

◆ async_subscribe_topics()

None homeassistant.components.mqtt.subscription.async_subscribe_topics ( HomeAssistant  hass,
dict[str, EntitySubscription sub_state 
)
(Re)Subscribe to a set of MQTT topics.

Definition at line 139 of file subscription.py.

◆ async_subscribe_topics_internal()

None homeassistant.components.mqtt.subscription.async_subscribe_topics_internal ( HomeAssistant  hass,
dict[str, EntitySubscription sub_state 
)
(Re)Subscribe to a set of MQTT topics.

This function is internal to the MQTT integration and should not be called
from outside the integration.

Definition at line 148 of file subscription.py.

◆ async_unsubscribe_topics()

dict[str, EntitySubscription] homeassistant.components.mqtt.subscription.async_unsubscribe_topics ( HomeAssistant  hass,
dict[str, EntitySubscription] | None   sub_state 
)
Unsubscribe from all MQTT topics managed by async_subscribe_topics.

Definition at line 163 of file subscription.py.

Variable Documentation

◆ async_unsubscribe_topics

homeassistant.components.mqtt.subscription.async_unsubscribe_topics = partial(async_prepare_subscribe_topics, topics={})

Definition at line 169 of file subscription.py.