mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix mqtt subscription signature (#130866)
This commit is contained in:
parent
40fb28a94d
commit
db5cc4fcd4
@ -86,7 +86,7 @@ class EntitySubscription:
|
|||||||
@callback
|
@callback
|
||||||
def async_prepare_subscribe_topics(
|
def async_prepare_subscribe_topics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
new_state: dict[str, EntitySubscription] | None,
|
sub_state: dict[str, EntitySubscription] | None,
|
||||||
topics: dict[str, dict[str, Any]],
|
topics: dict[str, dict[str, Any]],
|
||||||
) -> dict[str, EntitySubscription]:
|
) -> dict[str, EntitySubscription]:
|
||||||
"""Prepare (re)subscribe to a set of MQTT topics.
|
"""Prepare (re)subscribe to a set of MQTT topics.
|
||||||
@ -101,8 +101,9 @@ def async_prepare_subscribe_topics(
|
|||||||
sets of topics. Every call to async_subscribe_topics must always
|
sets of topics. Every call to async_subscribe_topics must always
|
||||||
contain _all_ the topics the subscription state should manage.
|
contain _all_ the topics the subscription state should manage.
|
||||||
"""
|
"""
|
||||||
current_subscriptions = new_state if new_state is not None else {}
|
current_subscriptions: dict[str, EntitySubscription]
|
||||||
new_state = {}
|
current_subscriptions = sub_state if sub_state is not None else {}
|
||||||
|
sub_state = {}
|
||||||
for key, value in topics.items():
|
for key, value in topics.items():
|
||||||
# Extract the new requested subscription
|
# Extract the new requested subscription
|
||||||
requested = EntitySubscription(
|
requested = EntitySubscription(
|
||||||
@ -119,7 +120,7 @@ def async_prepare_subscribe_topics(
|
|||||||
# Get the current subscription state
|
# Get the current subscription state
|
||||||
current = current_subscriptions.pop(key, None)
|
current = current_subscriptions.pop(key, None)
|
||||||
requested.resubscribe_if_necessary(hass, current)
|
requested.resubscribe_if_necessary(hass, current)
|
||||||
new_state[key] = requested
|
sub_state[key] = requested
|
||||||
|
|
||||||
# Go through all remaining subscriptions and unsubscribe them
|
# Go through all remaining subscriptions and unsubscribe them
|
||||||
for remaining in current_subscriptions.values():
|
for remaining in current_subscriptions.values():
|
||||||
@ -132,7 +133,7 @@ def async_prepare_subscribe_topics(
|
|||||||
remaining.entity_id,
|
remaining.entity_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
return new_state
|
return sub_state
|
||||||
|
|
||||||
|
|
||||||
async def async_subscribe_topics(
|
async def async_subscribe_topics(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user