From 722a3d73a580efa324b99189ca4602e66b481c14 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Sat, 1 Feb 2025 12:57:42 -0500 Subject: [PATCH] device: recover from errors in ping --- lib/logitech_receiver/device.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index eee773bd5..10199fec1 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -540,7 +540,10 @@ def ping(self): self.hidpp_long is None and (self.bluetooth or self._protocol is not None and self._protocol >= 2.0) ) handle = self.handle or self.receiver.handle - protocol = self.low_level.ping(handle, self.number, long_message=long) + try: + protocol = self.low_level.ping(handle, self.number, long_message=long) + except exceptions.NoReceiver: # if ping fails, device is offline + protocol = None self.online = protocol is not None if protocol: self._protocol = protocol