From 34e70778a51fbd23bc78626e9dc3405dc441bb35 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 21 Feb 2023 22:28:27 +0100 Subject: [PATCH] Deprecated callback removed for MQTT subscribe (#1692) * Deprecated callback removed for MQTT subscribe * Update blog/2023-02-21-deprecated-callback-removed.md Co-authored-by: Erik Montnemery --------- Co-authored-by: Erik Montnemery --- .../2023-02-21-deprecated-callback-removed.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 blog/2023-02-21-deprecated-callback-removed.md diff --git a/blog/2023-02-21-deprecated-callback-removed.md b/blog/2023-02-21-deprecated-callback-removed.md new file mode 100644 index 00000000..93175e59 --- /dev/null +++ b/blog/2023-02-21-deprecated-callback-removed.md @@ -0,0 +1,33 @@ +--- +author: Jan Bouwhuis +authorURL: https://twitter.com/jbouwh +title: Deprecated callback signatures for MQTT subscribe removed +--- + +Home Assistant's MQTT integration [no longer supports](https://github.com/home-assistant/core/pull/88543) +deprecated callback signatures for MQTT subscribe. + +Custome integrations that still used the deprecated callback signature for the callback function on MQTT subscribe will break unless updated. An exception will be raised if a not supported callback type is detected. + +Examples of deprecated callback functions that will no longer work: + +```python +async def async_deprecated_callback1(topic: str, payload: ReceivePayloadType, qos: int) -> None: + """Deprecated async callback example 1.""" + ... + + +@callback +def async_deprecated_callback2(topic: str, payload: ReceivePayloadType, qos: int) -> None: + """Deprecated async callback example 2.""" + ... +``` + +Example of a correct callback signature: + +```python +@callback +def async_correct_callback(msg: msg: ReceiveMessage) -> None: + """Callback example 1.""" + ... +```