From db5cc4fcd4dca217fb0ab68e063572e5d7f4778a Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Mon, 18 Nov 2024 14:19:11 +0100 Subject: [PATCH] Fix mqtt subscription signature (#130866) --- homeassistant/components/mqtt/subscription.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/mqtt/subscription.py b/homeassistant/components/mqtt/subscription.py index 3f3f67970f3..08d501ede12 100644 --- a/homeassistant/components/mqtt/subscription.py +++ b/homeassistant/components/mqtt/subscription.py @@ -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(