A more elegant logic to infer the manufacturer name.

This commit is contained in:
Fabio Manganiello 2023-03-19 12:54:52 +01:00
parent b568876474
commit 6e9263c4e4
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -236,9 +236,7 @@ def device_to_entity(device: BLEDevice, data: AdvertisementData) -> BluetoothDev
theengs_entity = _parse_advertisement_data(data) theengs_entity = _parse_advertisement_data(data)
props = (device.details or {}).get('props', {}) props = (device.details or {}).get('props', {})
manufacturer = theengs_entity.manufacturer or company.get( manufacturer = theengs_entity.manufacturer or company.get(
list(device.metadata['manufacturer_data'].keys())[0] next(iter(key for key in device.metadata['manufacturer_data']), 0xFFFF)
if device.metadata.get('manufacturer_data', {})
else None
) )
parent_entity = BluetoothDevice( parent_entity = BluetoothDevice(