Fix mqtt subscription signature (#130866)

This commit is contained in:
Jan Bouwhuis 2024-11-18 14:19:11 +01:00 committed by GitHub
parent 40fb28a94d
commit db5cc4fcd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -86,7 +86,7 @@ class EntitySubscription:
@callback
def async_prepare_subscribe_topics(
hass: HomeAssistant,
new_state: dict[str, EntitySubscription] | None,
sub_state: dict[str, EntitySubscription] | None,
topics: dict[str, dict[str, Any]],
) -> dict[str, EntitySubscription]:
"""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
contain _all_ the topics the subscription state should manage.
"""
current_subscriptions = new_state if new_state is not None else {}
new_state = {}
current_subscriptions: dict[str, EntitySubscription]
current_subscriptions = sub_state if sub_state is not None else {}
sub_state = {}
for key, value in topics.items():
# Extract the new requested subscription
requested = EntitySubscription(
@ -119,7 +120,7 @@ def async_prepare_subscribe_topics(
# Get the current subscription state
current = current_subscriptions.pop(key, None)
requested.resubscribe_if_necessary(hass, current)
new_state[key] = requested
sub_state[key] = requested
# Go through all remaining subscriptions and unsubscribe them
for remaining in current_subscriptions.values():
@ -132,7 +133,7 @@ def async_prepare_subscribe_topics(
remaining.entity_id,
)
return new_state
return sub_state
async def async_subscribe_topics(