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:
Pascal Vizeli
2016-11-18 23:35:08 +01:00
committed by GitHub
parent 265232af98
commit c56f99baaf
7 changed files with 233 additions and 120 deletions

View File

@@ -51,7 +51,10 @@ def detect_location_info():
def distance(lat1, lon1, lat2, lon2):
"""Calculate the distance in meters between two points."""
"""Calculate the distance in meters between two points.
Async friendly.
"""
return vincenty((lat1, lon1), (lat2, lon2)) * 1000
@@ -88,6 +91,8 @@ def vincenty(point1: Tuple[float, float], point2: Tuple[float, float],
Result in kilometers or miles between two points on the surface of a
spheroid.
Async friendly.
"""
# short-circuit coincident points
if point1[0] == point2[0] and point1[1] == point2[1]: