From 8aea8fb2ae7bd5f6e8b03badfc4dcb5394402efd Mon Sep 17 00:00:00 2001 From: pmessan Date: Fri, 17 Jan 2025 15:39:43 +0100 Subject: [PATCH] fix(client): Ensure that the bus is connected before pairing If pairing is attempted before the bus is connected, the pairing process fails due to an exception being raised. --- AUTHORS.rst | 1 + CHANGELOG.rst | 4 ++++ bleak/backends/bluezdbus/client.py | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index b6eca00d..6bff3be3 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -24,6 +24,7 @@ Contributors * David Johansen * JP Hutchins * Bram Duvigneau +* Peter-Newman Messan Sponsors -------- diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9c360d48..fa1df846 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,10 @@ and this project adheres to `Semantic Versioning bool: Boolean regarding success of pairing. """ + if self._bus is None: + self._bus = await MessageBus( + bus_type=BusType.SYSTEM, negotiate_unix_fd=True + ).connect() + # See if it is already paired. reply = await self._bus.call( Message(