Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions custom_components/dawarich/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ATTR_SOURCE_TYPE,
SourceType,
)
from homeassistant.components.person.const import PersonEntityStateAttribute
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
from homeassistant.components.sensor.const import SensorDeviceClass, SensorStateClass
from homeassistant.const import (
Expand Down Expand Up @@ -279,15 +280,18 @@ async def _async_update_callback(self, event):

# Check if the coordinates are present
if latitude is None or longitude is None:
if new_data.get(ATTR_SOURCE_TYPE) != SourceType.GPS:
source_type = new_data.get(ATTR_SOURCE_TYPE)
if source_type is None:
source_type = new_data.get(PersonEntityStateAttribute.SOURCE)
if source_type != SourceType.GPS:
_LOGGER.warning(
(
"The choosen device tracker (%s) is emitting a '%s' "
"source type which typically does not have coordinates. "
"Please change the device tracker to one that provides GPS coordinates."
),
self._mobile_app,
new_data.get(ATTR_SOURCE_TYPE),
source_type,
)
_LOGGER.debug("Coordinates are not present, skipping update")
return
Expand Down
Loading