From b2f9df965a51b601312ae50b03d61ae1b8cf570c Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Sun, 25 Sep 2022 03:48:58 -0400 Subject: [PATCH] device: use ADC notifications to set device inactive and active --- lib/logitech_receiver/notifications.py | 2 ++ lib/logitech_receiver/status.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/logitech_receiver/notifications.py b/lib/logitech_receiver/notifications.py index 0cfc142c..b746406b 100644 --- a/lib/logitech_receiver/notifications.py +++ b/lib/logitech_receiver/notifications.py @@ -343,6 +343,8 @@ def _process_feature_notification(device, status, n, feature): if result: _ignore, level, next, battery_status, voltage = result status.set_battery_info(level, next, battery_status, voltage) + else: # this feature is used to signal device becoming inactive + status.changed(active=False) else: _log.warn('%s: unknown ADC MEASUREMENT %s', device, n) diff --git a/lib/logitech_receiver/status.py b/lib/logitech_receiver/status.py index bce7fea6..ca9bc5c8 100644 --- a/lib/logitech_receiver/status.py +++ b/lib/logitech_receiver/status.py @@ -237,7 +237,7 @@ class DeviceStatus(dict): else: reason = _('Battery: %(percent)d%% (%(status)s)') % {'percent': level, 'status': status.name} - if changed or reason: + if changed or reason or not self._active: # a battery response means device is active # update the leds on the device, if any _hidpp10.set_3leds(self._device, level, charging=charging, warning=bool(alert)) self.changed(active=True, alert=alert, reason=reason, timestamp=timestamp)