mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Handle blank string in location name for mobile app (#51130)
This commit is contained in:
parent
38e0cbe964
commit
3e7729faf2
@ -94,7 +94,9 @@ class MobileAppEntity(TrackerEntity, RestoreEntity):
|
|||||||
@property
|
@property
|
||||||
def location_name(self):
|
def location_name(self):
|
||||||
"""Return a location name for the current location of the device."""
|
"""Return a location name for the current location of the device."""
|
||||||
return self._data.get(ATTR_LOCATION_NAME)
|
if location_name := self._data.get(ATTR_LOCATION_NAME):
|
||||||
|
return location_name
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -48,6 +48,7 @@ async def test_sending_location(hass, create_registrations, webhook_client):
|
|||||||
"course": 6,
|
"course": 6,
|
||||||
"speed": 7,
|
"speed": 7,
|
||||||
"vertical_accuracy": 8,
|
"vertical_accuracy": 8,
|
||||||
|
"location_name": "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -82,7 +83,6 @@ async def test_restoring_location(hass, create_registrations, webhook_client):
|
|||||||
"course": 60,
|
"course": 60,
|
||||||
"speed": 70,
|
"speed": 70,
|
||||||
"vertical_accuracy": 80,
|
"vertical_accuracy": 80,
|
||||||
"location_name": "bar",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -104,6 +104,7 @@ async def test_restoring_location(hass, create_registrations, webhook_client):
|
|||||||
|
|
||||||
assert state_1 is not state_2
|
assert state_1 is not state_2
|
||||||
assert state_2.name == "Test 1"
|
assert state_2.name == "Test 1"
|
||||||
|
assert state_2.state == "not_home"
|
||||||
assert state_2.attributes["source_type"] == "gps"
|
assert state_2.attributes["source_type"] == "gps"
|
||||||
assert state_2.attributes["latitude"] == 10
|
assert state_2.attributes["latitude"] == 10
|
||||||
assert state_2.attributes["longitude"] == 20
|
assert state_2.attributes["longitude"] == 20
|
||||||
|
Loading…
x
Reference in New Issue
Block a user