mirror of
https://github.com/home-assistant/core.git
synced 2026-10-06 06:15:47 -04:00
Fix Tile timestamps shifted by the local UTC offset (#183639)
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user