From 913ef6f8cd5d2cfb8eb4764ed0a69b13523b4ecc Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 24 Mar 2023 01:56:19 +0100 Subject: [PATCH] Refresh `BluetoothDevice.reachable` when a device is found/lost. --- platypush/plugins/bluetooth/_ble/_event_handler.py | 1 + platypush/plugins/bluetooth/_cache.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/platypush/plugins/bluetooth/_ble/_event_handler.py b/platypush/plugins/bluetooth/_ble/_event_handler.py index 6a679a8670..3beedfeea2 100644 --- a/platypush/plugins/bluetooth/_ble/_event_handler.py +++ b/platypush/plugins/bluetooth/_ble/_event_handler.py @@ -183,6 +183,7 @@ class EventHandler: get_bus().post(event) if events: + new_entity.reachable = True self._device_queue.put_nowait(new_entity) @staticmethod diff --git a/platypush/plugins/bluetooth/_cache.py b/platypush/plugins/bluetooth/_cache.py index 4c6923b4c7..02c75903a5 100644 --- a/platypush/plugins/bluetooth/_cache.py +++ b/platypush/plugins/bluetooth/_cache.py @@ -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(