Skip to content
Merged
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
28 changes: 18 additions & 10 deletions homeassistant/components/tile/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CoordinatorEntity,
DataUpdateCoordinator,
)
from homeassistant.util.dt import as_utc

from . import TileData
from .const import DOMAIN
Expand Down Expand Up @@ -145,16 +146,23 @@ def _handle_coordinator_update(self) -> None:
@callback
def _update_from_latest_data(self) -> None:
"""Update the entity from the latest data."""
self._attr_extra_state_attributes.update(
{
ATTR_ALTITUDE: self._tile.altitude,
ATTR_IS_LOST: self._tile.lost,
ATTR_LAST_LOST_TIMESTAMP: self._tile.lost_timestamp,
ATTR_LAST_TIMESTAMP: self._tile.last_timestamp,
ATTR_RING_STATE: self._tile.ring_state,
ATTR_VOIP_STATE: self._tile.voip_state,
}
)
self._attr_extra_state_attributes = {
ATTR_ALTITUDE: self._tile.altitude,
ATTR_IS_LOST: self._tile.lost,
ATTR_RING_STATE: self._tile.ring_state,
ATTR_VOIP_STATE: self._tile.voip_state,
}
for timestamp_attr in (
(ATTR_LAST_LOST_TIMESTAMP, self._tile.lost_timestamp),
(ATTR_LAST_TIMESTAMP, self._tile.last_timestamp),
):
if not timestamp_attr[1]:
# 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]
)

async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
Expand Down