-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbca65d
commit 3e2a00e
Showing
8 changed files
with
230 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Util functions for the dwd_weather_warnings integration.""" | ||
|
||
from __future__ import annotations | ||
|
||
from homeassistant.core import HomeAssistant | ||
|
||
from .const import LOGGER | ||
|
||
|
||
def get_position_data( | ||
hass: HomeAssistant, device_tracker: str | ||
) -> tuple[float, float] | None: | ||
"""Extract longitude and latitude from a device tracker.""" | ||
entity = hass.states.get(device_tracker) | ||
if entity is None: | ||
return None | ||
|
||
latitude = entity.attributes.get("latitude") | ||
if not latitude: | ||
LOGGER.warning( | ||
"Failed to find attribute 'latitude' in device_tracker %s", entity | ||
) | ||
return None | ||
|
||
longitude = entity.attributes.get("longitude") | ||
if not longitude: | ||
LOGGER.warning( | ||
"Failed to find attribute 'longitude' in device_tracker %s", entity | ||
) | ||
return None | ||
|
||
return (latitude, longitude) |
Oops, something went wrong.