Fix Tile timestamps shifted by the local UTC offset (#183639)

This commit is contained in:
Bilal Atique
2026-09-30 11:22:36 +01:00
committed by GitHub
parent 40425ef265
commit 15eb4345d1
2 changed files with 7 additions and 6 deletions
@@ -6,7 +6,7 @@ from typing import override
from homeassistant.components.device_tracker import TrackerEntity
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.util.dt import as_utc
from homeassistant.util import dt as dt_util
from .coordinator import TileConfigEntry, TileCoordinator
from .entity import TileEntity
@@ -81,9 +81,10 @@ class TileDeviceTracker(TileEntity, TrackerEntity):
# If the API doesn't return a value for a particular timestamp
# attribute, skip it:
continue
self._attr_extra_state_attributes[timestamp_attr[0]] = as_utc(
timestamp_attr[1]
)
# pytile returns naive datetimes that hold UTC, not local time:
self._attr_extra_state_attributes[timestamp_attr[0]] = timestamp_attr[
1
].replace(tzinfo=dt_util.UTC)
@override
async def async_added_to_hass(self) -> None:
@@ -47,8 +47,8 @@
<DeviceTrackerEntityStateAttribute.IN_ZONES: 'in_zones'>: list([
]),
'is_lost': False,
'last_lost_timestamp': datetime.datetime(1970, 1, 1, 3, 0, tzinfo=datetime.timezone.utc),
'last_timestamp': datetime.datetime(2020, 8, 13, 0, 55, 26, tzinfo=datetime.timezone.utc),
'last_lost_timestamp': datetime.datetime(1969, 12, 31, 19, 0, tzinfo=datetime.timezone.utc),
'last_timestamp': datetime.datetime(2020, 8, 12, 17, 55, 26, tzinfo=datetime.timezone.utc),
<EntityStateAttribute.LATITUDE: 'latitude'>: 1,
<EntityStateAttribute.LONGITUDE: 'longitude'>: 1,
'ring_state': 'STOPPED',