Repository: pwr-Solaar/Solaar

Issue:
There is no option for MX Anywhere 3 and uknown battery
I manual installed Solaar 1.1.1rc2. After executing Solaar, there is no option available for MX Anywhere 3 and with unknown battery.

![image](https://user-images.githubusercontent.com/46984555/147038438-d1f0eba7-db7d-4984-81b6-ce92c5a6fe4d.png)

- Solaar version: 1.1.1rc2
- Distribution: Ubuntu 18.04
- Kernel version: 5.4.0-91-generic
- Output of solaar -dd show

> $ solaar -dd show
> 12:35:26,311    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Down"
> 12:35:26,311    DEBUG [MainThread] logitech_receiver.diversion: rule Key assuming action "pressed" for "Brightness Up"
> 12:35:26,315    DEBUG [MainThread] solaar.ui.tray: using StatusIcon
> 12:35:26,339    DEBUG [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C52B INTERFACE 2 FILTER 2
> 12:35:26,339     INFO [MainThread] logitech_receiver.base: New lock 10
> 12:35:26,340    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 83B5 030000]
> 12:35:26,343    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 FF 83B5 0333C199571406080000000000000000]
> 12:35:26,343    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 80B2 000000]
> 12:35:26,345    DEBUG [MainThread] logitech_receiver.base: (10) => r[20 01 4101 9040040000000400000000]
> 12:35:26,347    DEBUG [MainThread] logitech_receiver.base: (10) => r[20 00 4102 0000000000000000000000]
> 12:35:26,349    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 8F80 B20300]
> 12:35:26,349    DEBUG [MainThread] logitech_receiver.base: (10) device 0xFF error on request {80B2}: 3 = invalid value
> 12:35:26,349    DEBUG [MainThread] solaar.cli: [/dev/hidraw0] => <UnifyingReceiver(/dev/hidraw0,10)>
> 12:35:26,354    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 8102 000000]
> 12:35:26,355    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 8102 000100]
> Unifying Receiver
>   Device path  : /dev/hidraw0
>   USB id       : 046d:C52B
>   Serial       : 33C19957
> 12:35:26,355    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 81F1 010000]
> 12:35:26,357    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 81F1 012411]
> 12:35:26,357    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 81F1 020000]
> 12:35:26,359    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 81F1 020036]
> 12:35:26,359    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 81F1 040000]
> 12:35:26,361    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 81F1 040209]
> 12:35:26,361    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 81F1 030000]
> 12:35:26,363    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 81F1 03AAAC]
>     Firmware   : 24.11.B0036
>     Bootloader : 02.09
>     Other      : AA.AC
>   Has 1 paired device(s) out of a maximum of 6.
> 12:35:26,363    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 8102 000000]
> 12:35:26,365    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 8102 000100]
> 12:35:26,365    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 8100 000000]
> 12:35:26,367    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 8100 000100]
>   Notifications: wireless (0x000100)
> 12:35:26,367    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 83B3 000000]
> 12:35:26,369    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 FF 83B3 35000000000000000000000000000000]
>   Device activity counters: 1=53
> 12:35:26,369    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 8102 000000]
> 12:35:26,371    DEBUG [MainThread] logitech_receiver.base: (10) => r[10 FF 8102 000100]
> 12:35:26,371    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 83B5 200000]
> 12:35:26,373    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 FF 83B5 20080840900402020600000000000000]
> 12:35:26,375    DEBUG [MainThread] logitech_receiver.base: (10) <= w[10 FF 83B5 400000]
> 12:35:26,377    DEBUG [MainThread] logitech_receiver.base: (10) => r[11 FF 83B5 400D4D5820416E797768657265203300]
> 12:35:26,377     INFO [MainThread] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw0,10)>: found new device 1 (4090)
> 
> solaar: error: Traceback (most recent call last):
>   File "/home/abel/.local/lib/python3.6/site-packages/solaar/cli/__init__.py", line 204, in run
>     m.run(c, args, _find_receiver, _find_device)
>   File "/home/abel/.local/lib/python3.6/site-packages/solaar/cli/show.py", line 285, in run
>     _print_device(dev)
>   File "/home/abel/.local/lib/python3.6/site-packages/solaar/cli/show.py", line 89, in _print_device
>     dev.ping()
>   File "/home/abel/.local/lib/python3.6/site-packages/logitech_receiver/device.py", line 401, in ping
>     self.handle or self.receiver.handle, self.number, long_message=self.bluetooth or self._protocol >= 2.0
> TypeError: '>=' not supported between instances of 'NoneType' and 'float'




Discussion:

Resolving patch:
diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py
--- a/lib/logitech_receiver/device.py
+++ b/lib/logitech_receiver/device.py
@@ -397,9 +397,8 @@ def feature_request(self, feature, function=0x00, *params, no_reply=False):
 
     def ping(self):
         """Checks if the device is online, returns True of False"""
-        protocol = _base.ping(
-            self.handle or self.receiver.handle, self.number, long_message=self.bluetooth or self._protocol >= 2.0
-        )
+        long = self.bluetooth or self._protocol is not None and self._protocol >= 2.0
+        protocol = _base.ping(self.handle or self.receiver.handle, self.number, long_message=long)
         self.online = protocol is not None
         if protocol:
             self._protocol = protocol


Test patch: