Correct logic for picking bluetooth local name (#102823)

* Correct logic for picking bluetooth local name

* make test more robust

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Erik Montnemery 2023-10-26 01:08:31 +02:00 committed by GitHub
parent 69a0c0d435
commit 64f0ea60d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View file

@ -330,7 +330,7 @@ class BaseHaRemoteScanner(BaseHaScanner):
prev_manufacturer_data = prev_advertisement.manufacturer_data
prev_name = prev_device.name
if local_name and prev_name and len(prev_name) > len(local_name):
if prev_name and (not local_name or len(prev_name) > len(local_name)):
local_name = prev_name
if service_uuids and service_uuids != prev_service_uuids: