Refresh `BluetoothDevice.reachable` when a device is found/lost.

This commit is contained in:
Fabio Manganiello 2023-03-24 01:56:19 +01:00
parent d46d4e2300
commit 913ef6f8cd
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
2 changed files with 5 additions and 0 deletions

View File

@ -183,6 +183,7 @@ class EventHandler:
get_bus().post(event)
if events:
new_entity.reachable = True
self._device_queue.put_nowait(new_entity)
@staticmethod

View File

@ -176,6 +176,10 @@ class EntityCache(BaseCache):
if getattr(existing_device, attr, None) is None:
setattr(existing_device, attr, getattr(device, attr, None))
# Coalesce the reachable flag
if device.reachable is not None:
existing_device.reachable = device.reachable
# Merge the data and meta dictionaries
for attr in ('data', 'meta'):
setattr(