diff --git a/homeassistant/components/mqtt/client.py b/homeassistant/components/mqtt/client.py index 414027776a3..36e12c47419 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -152,6 +152,7 @@ DeprecatedMessageCallbackTypes = Union[ ] +# Support for a deprecated callback type will be removed from HA core 2023.2.0 def wrap_msg_callback( msg_callback: DeprecatedMessageCallbackTypes, ) -> AsyncMessageCallbackType | MessageCallbackType: @@ -203,6 +204,7 @@ async def async_subscribe( raise HomeAssistantError( f"Cannot subscribe to topic '{topic}', MQTT is not enabled" ) + # Support for a deprecated callback type will be removed from HA core 2023.2.0 # Count callback parameters which don't have a default value non_default = 0 if msg_callback: @@ -216,7 +218,8 @@ async def async_subscribe( if non_default == 3: module = inspect.getmodule(msg_callback) _LOGGER.warning( - "Signature of MQTT msg_callback '%s.%s' is deprecated", + "Signature of MQTT msg_callback '%s.%s' is deprecated, " + "this will stop working with HA core 2023.2", module.__name__ if module else "", msg_callback.__name__, ) diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index 2e4a44b9525..12b36a2fae3 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -882,6 +882,7 @@ async def test_subscribe_bad_topic( await mqtt.async_subscribe(hass, 55, record_calls) +# Support for a deprecated callback type will be removed from HA core 2023.2.0 async def test_subscribe_deprecated(hass, mqtt_mock_entry_no_yaml_config): """Test the subscription of a topic using deprecated callback signature.""" mqtt_mock = await mqtt_mock_entry_no_yaml_config() @@ -930,6 +931,7 @@ async def test_subscribe_deprecated(hass, mqtt_mock_entry_no_yaml_config): assert len(calls) == 1 +# Support for a deprecated callback type will be removed from HA core 2023.2.0 async def test_subscribe_deprecated_async(hass, mqtt_mock_entry_no_yaml_config): """Test the subscription of a topic using deprecated coroutine signature.""" mqtt_mock = await mqtt_mock_entry_no_yaml_config()