Make the device_tracker more forgiving when passed an empty ip address string (#91101)

This has come up over and over and over again

fixes #87165 fixes #51980
This commit is contained in:
J. Nick Koston 2023-04-08 16:32:56 -10:00 committed by GitHub
parent 69f751703b
commit 5f0d983df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 19 deletions

View file

@ -348,7 +348,7 @@ class ScannerEntity(BaseTrackerEntity):
self.mac_address,
self.unique_id,
)
if self.is_connected:
if self.is_connected and self.ip_address:
_async_connected_device_registered(
hass,
self.mac_address,
@ -405,7 +405,7 @@ class ScannerEntity(BaseTrackerEntity):
"""Return the device state attributes."""
attr: dict[str, StateType] = {}
attr.update(super().state_attributes)
if self.ip_address is not None:
if self.ip_address:
attr[ATTR_IP] = self.ip_address
if self.mac_address is not None:
attr[ATTR_MAC] = self.mac_address