diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index 13d2c817..92296b7d 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -195,9 +195,9 @@ CHARGE_STATUS = _NamedInts( error=0x07) CHARGE_LEVEL = _NamedInts( - average=0x00, - full=0x01, - critical=0x02) + average=50, + full=90, + critical=5) CHARGE_TYPE = _NamedInts( standard=0x00, @@ -513,10 +513,7 @@ def get_name(device): def get_battery(device): - """Reads a device's battery level. - - :raises FeatureNotSupported: if the device does not support this feature. - """ + """Reads a device's battery level.""" battery = feature_request(device, FEATURE.BATTERY_STATUS) if battery: discharge, dischargeNext, status = _unpack('!BBB', battery[:3]) diff --git a/lib/logitech_receiver/status.py b/lib/logitech_receiver/status.py index 821dd002..ded08c6e 100644 --- a/lib/logitech_receiver/status.py +++ b/lib/logitech_receiver/status.py @@ -229,6 +229,12 @@ class DeviceStatus(dict): battery = _hidpp10.get_battery(d) else: battery = _hidpp20.get_battery(d) + if battery is None: + v = _hidpp20.get_voltage(d) + if v is not None: + _, charging, status, level, _ = v + status = _hidpp20.BATTERY_STATUS.recharging if status == _hidpp20.BATTERY_STATUS.recharging else _hidpp20.BATTERY_STATUS.discharging + battery = ( level, status, None ) # Really unnecessary, if the device has SOLAR_DASHBOARD it should be # broadcasting it's battery status anyway, it will just take a little while.