diff --git a/lib/logitech/unifying_receiver/hidpp10.py b/lib/logitech/unifying_receiver/hidpp10.py index 38b77356..a7af40e6 100644 --- a/lib/logitech/unifying_receiver/hidpp10.py +++ b/lib/logitech/unifying_receiver/hidpp10.py @@ -94,8 +94,16 @@ def get_battery(device): reply = get_register(device, 'battery_status', 0x07) if reply: - battery_status = ord(reply[:1]) - _log.info("%s: battery status %02X", device, battery_status) + level = ord(reply[:1]) + battery_status = ord(reply[2:3]) + charge = (90 if level == 7 # full + else 50 if level == 5 # good + else 20 if level == 3 # low + else 5 if level == 1 # critical + else 0 ) # wtf? + status = ('charging' if battery_status == 0x25 + else 'discharging') + return charge, status def get_serial(device):