From 6e9263c4e4c9638a978ba5d2026f050294347e1c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 19 Mar 2023 12:54:52 +0100 Subject: [PATCH] A more elegant logic to infer the manufacturer name. --- platypush/plugins/bluetooth/_ble/_mappers.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platypush/plugins/bluetooth/_ble/_mappers.py b/platypush/plugins/bluetooth/_ble/_mappers.py index e01ef65bc..4913ce475 100644 --- a/platypush/plugins/bluetooth/_ble/_mappers.py +++ b/platypush/plugins/bluetooth/_ble/_mappers.py @@ -236,9 +236,7 @@ def device_to_entity(device: BLEDevice, data: AdvertisementData) -> BluetoothDev theengs_entity = _parse_advertisement_data(data) props = (device.details or {}).get('props', {}) manufacturer = theengs_entity.manufacturer or company.get( - list(device.metadata['manufacturer_data'].keys())[0] - if device.metadata.get('manufacturer_data', {}) - else None + next(iter(key for key in device.metadata['manufacturer_data']), 0xFFFF) ) parent_entity = BluetoothDevice(