Repository: pwr-Solaar/Solaar

Issue:
Too few values in _battery_line
**Information**
<!-- Make sure that your issue is not one of the known issues in the Solaar documentation at https://pwr-solaar.github.io/Solaar/ -->
<!-- Do not bother opening an issue for a version older than 1.1.0.  Upgrade to the latest version and see if your issue persists. -->
<!-- If you not running the current version of Solaar, strongly consider upgrading to the newest version. -->
- Solaar version (`solaar --version` or `git describe --tags` if cloned from this repository): 1.1.5
- Distribution: Debian 11
- Kernel version (ex. `uname -srmo`): 5.10.140-1
- Output of `solaar show`:

<details>

```
Solaar version 1.1.5

Unifying Receiver
  Device path  : /dev/hidraw0
  USB id       : 046d:C52B
  Serial       : D4A19232
    Firmware   : 12.10.B0032
    Bootloader : 02.14
    Other      : AA.AA
  Has 1 paired device(s) out of a maximum of 6.
  Notifications: wireless (0x000100)
  Device activity counters: 1=198

  1: Marathon Mouse M705 (M-R0009)
     Device path  : /dev/hidraw1
     WPID         : 101B
     Codename     : M705 (M-R0009)
     Kind         : mouse
     Protocol     : HID++ 1.0
     Polling rate : 8 ms (125Hz)
     Serial number: 23691D3D
          Firmware: 17.01.B0017
        Bootloader: 02.06
             Other: 00.04
     The power switch is located on the base.
     Notifications: battery status (0x100000).
     Features: special buttons, scroll accel (0x420000)
solaar: error: Traceback (most recent call last):
  File "/usr/share/solaar/lib/solaar/cli/__init__.py", line 210, in run
    m.run(c, args, _find_receiver, _find_device)
  File "/usr/share/solaar/lib/solaar/cli/show.py", line 296, in run
    _print_device(dev)
  File "/usr/share/solaar/lib/solaar/cli/show.py", line 273, in _print_device
    _battery_line(dev)
  File "/usr/share/solaar/lib/solaar/cli/show.py", line 72, in _battery_line
    level, nextLevel, status, voltage = battery
ValueError: not enough values to unpack (expected 4, got 3)
```
</details>

- Contents of `~/.config/solaar/config.yaml` (or `~/.config/solaar/config.json` if `~/.config/solaar/config.yaml` not present):

<details>

```
{
  "101B:23691D3D": {
    "_name": "Marathon Mouse M705 (M-R0009)",
    "_sensitive": {
      "smooth-scroll": true
    },
    "_serial": "23691D3D",
    "side-scroll": true,
    "smooth-scroll": true
  },
  "_version": "1.0.7"
}
```
</details>


- Errors or warrnings from Solaar:
<!-- Under normal operation Solaar keeps a log of warning and error messages in ~/.tmp
while it is running as a file starting with 'Solaar'.
If this file is not available or does not have useful information you can
run Solaar as `solaar -dd`, after killing any running Solaar processes to
have Solaar log informational, warning, and error messages to stdout. -->


**Describe the bug**
`solaar show` fails with the following error:

```
solaar: error: Traceback (most recent call last):
  File "/usr/share/solaar/lib/solaar/cli/__init__.py", line 210, in run
    m.run(c, args, _find_receiver, _find_device)
  File "/usr/share/solaar/lib/solaar/cli/show.py", line 296, in run
    _print_device(dev)
  File "/usr/share/solaar/lib/solaar/cli/show.py", line 273, in _print_device
    _battery_line(dev)
  File "/usr/share/solaar/lib/solaar/cli/show.py", line 72, in _battery_line
    level, nextLevel, status, voltage = battery
ValueError: not enough values to unpack (expected 4, got 3)
```

**To Reproduce**
Steps to reproduce the behavior:
1. Run `solaar show` with a Logitech M705 mouse connected.


Discussion:

Resolving patch:
diff --git a/lib/logitech_receiver/hidpp10.py b/lib/logitech_receiver/hidpp10.py
--- a/lib/logitech_receiver/hidpp10.py
+++ b/lib/logitech_receiver/hidpp10.py
@@ -237,7 +237,7 @@ def parse_battery_status(register, reply):
             BATTERY_STATUS.discharging if status_byte == 0x30 else
             BATTERY_STATUS.recharging if status_byte == 0x50 else BATTERY_STATUS.full if status_byte == 0x90 else None
         )
-        return charge, status_text, None
+        return charge, None, status_text, None
 
     if register == REGISTERS.battery_status:
         status_byte = ord(reply[:1])
diff --git a/lib/logitech_receiver/notifications.py b/lib/logitech_receiver/notifications.py
--- a/lib/logitech_receiver/notifications.py
+++ b/lib/logitech_receiver/notifications.py
@@ -234,8 +234,8 @@ def _process_hidpp10_custom_notification(device, status, n):
         # message layout: 10 ix <register> <xx> <yy> <zz> <00>
         assert n.data[-1:] == b'\x00'
         data = chr(n.address).encode() + n.data
-        charge, status_text, next_charge = _hidpp10.parse_battery_status(n.sub_id, data)
-        status.set_battery_info(charge, next_charge, status_text, None)
+        charge, next_charge, status_text, voltage = _hidpp10.parse_battery_status(n.sub_id, data)
+        status.set_battery_info(charge, next_charge, status_text, voltage)
         return True
 
     if n.sub_id == _R.keyboard_illumination:


Test patch: