mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Handle short local names from esphome proxies (#79321)
This commit is contained in:
parent
d7d6637d79
commit
a01f18a3ac
@ -83,15 +83,23 @@ class ESPHomeScanner(BaseHaScanner):
|
|||||||
"""Call the registered callback."""
|
"""Call the registered callback."""
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
address = ":".join(TWO_CHAR.findall("%012X" % adv.address)) # must be upper
|
address = ":".join(TWO_CHAR.findall("%012X" % adv.address)) # must be upper
|
||||||
|
name = adv.name
|
||||||
|
if prev_discovery := self._discovered_devices.get(address):
|
||||||
|
# If the last discovery had the full local name
|
||||||
|
# and this one doesn't, keep the old one as we
|
||||||
|
# always want the full local name over the short one
|
||||||
|
if len(prev_discovery.name) > len(adv.name):
|
||||||
|
name = prev_discovery.name
|
||||||
|
|
||||||
advertisement_data = AdvertisementData( # type: ignore[no-untyped-call]
|
advertisement_data = AdvertisementData( # type: ignore[no-untyped-call]
|
||||||
local_name=None if adv.name == "" else adv.name,
|
local_name=None if name == "" else name,
|
||||||
manufacturer_data=adv.manufacturer_data,
|
manufacturer_data=adv.manufacturer_data,
|
||||||
service_data=adv.service_data,
|
service_data=adv.service_data,
|
||||||
service_uuids=adv.service_uuids,
|
service_uuids=adv.service_uuids,
|
||||||
)
|
)
|
||||||
device = BLEDevice( # type: ignore[no-untyped-call]
|
device = BLEDevice( # type: ignore[no-untyped-call]
|
||||||
address=address,
|
address=address,
|
||||||
name=adv.name,
|
name=name,
|
||||||
details=self._details,
|
details=self._details,
|
||||||
rssi=adv.rssi,
|
rssi=adv.rssi,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user