From cb288deb718008ff1bc2ab6bf6d7dbff836d0e2c Mon Sep 17 00:00:00 2001
From: Fabio Manganiello <fabio@manganiello.tech>
Date: Tue, 25 Apr 2023 16:19:11 +0200
Subject: [PATCH] Exclude more noisy BLE beacons.

Excluding Apple iBeacons and devices with no name and no services.
---
 platypush/plugins/bluetooth/_ble/_event_handler.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/platypush/plugins/bluetooth/_ble/_event_handler.py b/platypush/plugins/bluetooth/_ble/_event_handler.py
index 3beedfeea..4b206cbd1 100644
--- a/platypush/plugins/bluetooth/_ble/_event_handler.py
+++ b/platypush/plugins/bluetooth/_ble/_event_handler.py
@@ -191,6 +191,10 @@ class EventHandler:
         """
         Check if the beacon received from the given device should be skipped.
         """
+        # Exclude Apple iBeacons
+        if device.manufacturer == 'Apple, Inc.' and device.model == 'iBeacon':
+            return True
+
         # "Noisy" beacon devices usually have no associated friendly name. If a
         # device has a valid name, we should probably include it.
         if (
@@ -206,6 +210,10 @@ class EventHandler:
         ):
             return True
 
+        # If the device has no children and no manufacturer, skip it
+        if not (device.children and device.manufacturer):
+            return True
+
         # If the device has any children other than services, don't skip it
         if any(not isinstance(child, BluetoothService) for child in device.children):
             return False