mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Require core config detection to be triggerd manually (#24019)
* Detect core config * Remove elevation * Lint * Lint * Fix type
This commit is contained in:
@@ -65,30 +65,6 @@ def distance(lat1: Optional[float], lon1: Optional[float],
|
||||
return result * 1000
|
||||
|
||||
|
||||
async def async_get_elevation(session: aiohttp.ClientSession, latitude: float,
|
||||
longitude: float) -> int:
|
||||
"""Return elevation for given latitude and longitude."""
|
||||
try:
|
||||
resp = await session.get(ELEVATION_URL, params={
|
||||
'locations': '{},{}'.format(latitude, longitude),
|
||||
}, timeout=5)
|
||||
except (aiohttp.ClientError, asyncio.TimeoutError):
|
||||
return 0
|
||||
|
||||
if resp.status != 200:
|
||||
return 0
|
||||
|
||||
try:
|
||||
raw_info = await resp.json()
|
||||
except (aiohttp.ClientError, ValueError):
|
||||
return 0
|
||||
|
||||
try:
|
||||
return int(float(raw_info['results'][0]['elevation']))
|
||||
except (ValueError, KeyError, IndexError):
|
||||
return 0
|
||||
|
||||
|
||||
# Author: https://github.com/maurycyp
|
||||
# Source: https://github.com/maurycyp/vincenty
|
||||
# License: https://github.com/maurycyp/vincenty/blob/master/LICENSE
|
||||
|
||||
Reference in New Issue
Block a user