1 """Util functions for the dwd_weather_warnings integration."""
3 from __future__
import annotations
9 from .exceptions
import EntityNotFoundError
13 hass: HomeAssistant, registry_id: str
14 ) -> tuple[float, float] |
None:
15 """Extract longitude and latitude from a device tracker."""
16 registry = er.async_get(hass)
17 registry_entry = registry.async_get(registry_id)
18 if registry_entry
is None:
21 entity = hass.states.get(registry_entry.entity_id)
25 latitude = entity.attributes.get(ATTR_LATITUDE)
28 f
"Failed to find attribute '{ATTR_LATITUDE}' in {registry_entry.entity_id}",
32 longitude = entity.attributes.get(ATTR_LONGITUDE)
35 f
"Failed to find attribute '{ATTR_LONGITUDE}' in {registry_entry.entity_id}",
39 return (latitude, longitude)
tuple[float, float]|None get_position_data(HomeAssistant hass, str registry_id)