Bump paho-mqtt client to version 2.1.0 (#136130)

* Bump paho-mqtt client to version 2.1.0

* Remove commented code

* Bump pyeconet==0.1.26

* Ensure types-paho-mqtt==1.6.0.20240321 is uninstalled if test requirements are updated

* Update roombapy dependency

* Remove pyeconet from exceptions list

* Revert changes to install test requirements task
This commit is contained in:
Jan Bouwhuis
2025-02-04 20:59:28 +01:00
committed by GitHub
parent 56e07efe31
commit 7fa6f7e875
10 changed files with 27 additions and 25 deletions

View File

@ -15,7 +15,6 @@ import socket
import ssl
import time
from typing import TYPE_CHECKING, Any
import uuid
import certifi
@ -117,7 +116,7 @@ MAX_UNSUBSCRIBES_PER_CALL = 500
MAX_PACKETS_TO_READ = 500
type SocketType = socket.socket | ssl.SSLSocket | mqtt.WebsocketWrapper | Any
type SocketType = socket.socket | ssl.SSLSocket | mqtt._WebsocketWrapper | Any # noqa: SLF001
type SubscribePayloadType = str | bytes | bytearray # Only bytes if encoding is None
@ -309,12 +308,13 @@ class MqttClientSetup:
if (client_id := config.get(CONF_CLIENT_ID)) is None:
# PAHO MQTT relies on the MQTT server to generate random client IDs.
# However, that feature is not mandatory so we generate our own.
client_id = mqtt.base62(uuid.uuid4().int, padding=22)
client_id = None
transport: str = config.get(CONF_TRANSPORT, DEFAULT_TRANSPORT)
self._client = AsyncMQTTClient(
mqtt.CallbackAPIVersion.VERSION1,
client_id,
protocol=proto,
transport=transport,
transport=transport, # type: ignore[arg-type]
reconnect_on_failure=False,
)
self._client.setup()
@ -533,7 +533,7 @@ class MQTT:
try:
# Some operating systems do not allow us to set the preferred
# buffer size. In that case we try some other size options.
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, new_buffer_size)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, new_buffer_size) # type: ignore[union-attr]
except OSError as err:
if new_buffer_size <= MIN_BUFFER_SIZE:
_LOGGER.warning(
@ -1216,7 +1216,9 @@ class MQTT:
if not future.done():
future.set_exception(asyncio.TimeoutError)
async def _async_wait_for_mid_or_raise(self, mid: int, result_code: int) -> None:
async def _async_wait_for_mid_or_raise(
self, mid: int | None, result_code: int
) -> None:
"""Wait for ACK from broker or raise on error."""
if result_code != 0:
# pylint: disable-next=import-outside-toplevel
@ -1232,6 +1234,8 @@ class MQTT:
# Create the mid event if not created, either _mqtt_handle_mid or
# _async_wait_for_mid_or_raise may be executed first.
if TYPE_CHECKING:
assert mid is not None
future = self._async_get_mid_future(mid)
loop = self.hass.loop
timer_handle = loop.call_later(TIMEOUT_ACK, self._async_timeout_mid, future)
@ -1269,7 +1273,7 @@ def _matcher_for_topic(subscription: str) -> Callable[[str], bool]:
# pylint: disable-next=import-outside-toplevel
from paho.mqtt.matcher import MQTTMatcher
matcher = MQTTMatcher()
matcher = MQTTMatcher() # type: ignore[no-untyped-call]
matcher[subscription] = True
return lambda topic: next(matcher.iter_match(topic), False)
return lambda topic: next(matcher.iter_match(topic), False) # type: ignore[no-untyped-call]