@@ -147,6 +147,7 @@ def __init__(
147
147
self .battery_info = None
148
148
self .link_encrypted = None
149
149
self ._active = None # lags self.online - is used to help determine when to setup devices
150
+ self .present = True # used for devices that are integral with their receiver but that separately be disconnected
150
151
151
152
self ._feature_settings_checked = False
152
153
self ._gestures_lock = threading .Lock ()
@@ -432,6 +433,8 @@ def read_battery(self):
432
433
def changed (self , active = None , alert = Alert .NONE , reason = None , push = False ):
433
434
"""The status of the device had changed, so invoke the status callback.
434
435
Also push notifications and settings to the device when necessary."""
436
+ if logger .isEnabledFor (logging .DEBUG ):
437
+ logger .debug ("device %d changing: active=%s %s present=%s" , self .number , active , self ._active , self .present )
435
438
if active is not None :
436
439
self .online = active
437
440
was_active , self ._active = self ._active , active
@@ -533,7 +536,8 @@ def feature_request(self, feature, function=0x00, *params, no_reply=False):
533
536
return hidpp20 .feature_request (self , feature , function , * params , no_reply = no_reply )
534
537
535
538
def ping (self ):
536
- """Checks if the device is online, returns True of False"""
539
+ """Checks if the device is online and present, returns True of False.
540
+ Some devices are integral with their receiver but may not be present even if the receiver responds to ping."""
537
541
long = self .hidpp_long is True or (
538
542
self .hidpp_long is None and (self .bluetooth or self ._protocol is not None and self ._protocol >= 2.0 )
539
543
)
@@ -542,7 +546,7 @@ def ping(self):
542
546
protocol = self .low_level .ping (handle , self .number , long_message = long )
543
547
except exceptions .NoReceiver : # if ping fails, device is offline
544
548
protocol = None
545
- self .online = protocol is not None
549
+ self .online = protocol is not None and self . present
546
550
if protocol :
547
551
self ._protocol = protocol
548
552
return self .online
0 commit comments