device: use ADC notifications to set device inactive and active
This commit is contained in:
parent
cdf3957180
commit
b2f9df965a
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue