diff --git a/main.py b/main.py index 7d993e3..30fc27c 100644 --- a/main.py +++ b/main.py @@ -250,7 +250,21 @@ async def fetch_mqtt(): loop.create_task(process_mqtt(message)) +def suppress_hfp_rejection_error(loop, context): + exception = context.get('exception') + if isinstance(exception, DBusError) and 'HFP profile not supported' in str(exception): + # This is the expected error from AuthorizeService, so we can suppress the traceback. + logging.debug('Suppressed expected DBusError for HFP rejection.') + return + + # For all other exceptions, fall back to the default handler. + loop.default_exception_handler(context) + + async def main(): + loop = asyncio.get_running_loop() + loop.set_exception_handler(suppress_hfp_rejection_error) + global bus bus = await MessageBus(bus_type=BusType.SYSTEM).connect()