mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 19:09:32 +00:00
Async migration device_tracker (#4406)
* Async migration device_tracker * change location stuff to async * address paulus comments * fix lint & add async discovery listener * address paulus comments v2 * fix tests * fix test_mqtt * fix test_init * fix gps_acc * fix lint * change async_update_stale to callback
This commit is contained in:
@@ -8,7 +8,10 @@ from homeassistant.util import location as loc_util
|
||||
|
||||
|
||||
def has_location(state: State) -> bool:
|
||||
"""Test if state contains a valid location."""
|
||||
"""Test if state contains a valid location.
|
||||
|
||||
Async friendly.
|
||||
"""
|
||||
return (isinstance(state, State) and
|
||||
isinstance(state.attributes.get(ATTR_LATITUDE), float) and
|
||||
isinstance(state.attributes.get(ATTR_LONGITUDE), float))
|
||||
@@ -16,7 +19,10 @@ def has_location(state: State) -> bool:
|
||||
|
||||
def closest(latitude: float, longitude: float,
|
||||
states: Sequence[State]) -> State:
|
||||
"""Return closest state to point."""
|
||||
"""Return closest state to point.
|
||||
|
||||
Async friendly.
|
||||
"""
|
||||
with_location = [state for state in states if has_location(state)]
|
||||
|
||||
if not with_location:
|
||||
|
||||
Reference in New Issue
Block a user