Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update paho-mqtt to version 2.1.0 #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ha_mqtt_discoverable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,7 @@ def _setup_client(self, on_connect: Optional[Callable] = None) -> None:

mqtt_settings = self._settings.mqtt
logger.debug(f"Creating mqtt client ({mqtt_settings.client_name}) for {mqtt_settings.host}:{mqtt_settings.port}")
# Use named parameter to add compatibility with paho-mqtt >2.0.0
self.mqtt_client = mqtt.Client(client_id=mqtt_settings.client_name)
self.mqtt_client = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION2, client_id=mqtt_settings.client_name)
if mqtt_settings.tls_key:
logger.info(f"Connecting to {mqtt_settings.host}:{mqtt_settings.port} with SSL and client certificate authentication")
logger.debug(f"ca_certs={mqtt_settings.tls_ca_cert}")
Expand Down
11 changes: 6 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
requires-python = ">=3.10.0,<4.0"
dependencies = [
"pyaml==21.10.1",
"paho-mqtt==1.6.1",
"paho-mqtt==2.1.0",
"gitlike-commands (>=0.2.1,<0.4.0)",
"pydantic==2.7.2",
]
Expand Down
5 changes: 3 additions & 2 deletions tests/test_discoverable.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
MQTTv5,
SubscribeOptions,
)
from paho.mqtt.enums import CallbackAPIVersion
from pytest_mock import MockerFixture

from ha_mqtt_discoverable import DeviceInfo, Discoverable, EntityInfo, Settings
Expand Down Expand Up @@ -231,7 +232,7 @@ def message_callback(client: Client, userdata, message: MQTTMessage, tmp=None):

def test_publish_multithread(discoverable: Discoverable):
received_message = Event()
mqtt_client = Client(protocol=MQTTv5, userdata=received_message)
mqtt_client = Client(callback_api_version=CallbackAPIVersion.VERSION2, protocol=MQTTv5, userdata=received_message)

mqtt_client.connect(host="localhost")
mqtt_client.on_message = message_callback
Expand All @@ -258,7 +259,7 @@ def test_publish_multithread(discoverable: Discoverable):

def test_publish_async(discoverable: Discoverable):
received_message = Event()
mqtt_client = Client(protocol=MQTTv5, userdata=received_message)
mqtt_client = Client(callback_api_version=CallbackAPIVersion.VERSION2, protocol=MQTTv5, userdata=received_message)

mqtt_client.connect(host="localhost", clean_start=True)
mqtt_client.on_message = message_callback
Expand Down
Loading