Currently Tile devices show a last update timestamp probably from the last time a call was made to the Tile platform to receive the location. I have some devices with depleted batteries and within the Tile app I can see on which date the actual last location update (tracking) was done.
Not sure on which API this integration was build, but looking at this development; https://github.com/bachya/pytile more details can be retrieved.
If you’re handy with a text editor, you might be able to modify this file:
"""Support for Tile device trackers."""
import logging
from homeassistant.components.device_tracker.config_entry import TrackerEntity
from homeassistant.components.device_tracker.const import SOURCE_TYPE_GPS
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import ATTR_ATTRIBUTION, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import DATA_COORDINATOR, DATA_TILE, DOMAIN
_LOGGER = logging.getLogger(__name__)
ATTR_ALTITUDE = "altitude"
ATTR_CONNECTION_STATE = "connection_state"
ATTR_IS_DEAD = "is_dead"
ATTR_IS_LOST = "is_lost"
ATTR_LAST_LOST_TIMESTAMP = "last_lost_timestamp"
ATTR_RING_STATE = "ring_state"
This file has been truncated. show original
Add a new line on line 23:
ATTR_LAST_TIMESTAMP = "last_timestamp"
And another new line after line 141:
ATTR_LAST_TIMESTAMP: self._tile.last_timestamp,
I might submit a PR to add this myself. For now, this works.
jcconnell
(Jc Connell)
January 4, 2023, 6:42pm
3
Circling back here - I’ve submitted a PR to add this to Home Assistant.
home-assistant:dev
← jcconnell:add-tile-last-attr
opened 06:48AM - 04 Jan 23 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
-->
## Breaking change
<!--
If your PR contains a breaking change for existing users, it is important
to tell them what breaks, how to make it work again and why we did this.
This piece of text is published with the release notes, so it helps if you
write it towards our users, not us.
Note: Remove this section if this PR is NOT a breaking change.
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue in the
additional information section.
-->
This change includes the `last_timestamp` value from the API in the attributes of the Tile.
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: Could not find an issue.
- This PR is related to issue: Could not find an issue.
- Link to documentation pull request: No documentation change required.
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [x] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] The code has been formatted using Black (`black --fast homeassistant tests`)
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.
Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.
Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to `.coveragerc`.
<!--
This project is very active and we have a high turnover of pull requests.
Unfortunately, the number of incoming pull requests is higher than what our
reviewers can review and merge so there is a long backlog of pull requests
waiting for review. You can help here!
By reviewing another pull request, you will help raise the code quality of
that pull request and the final review will be faster. This way the general
pace of pull request reviews will go up and your wait time will go down.
When picking a pull request to review, try to choose one that hasn't yet
been reviewed.
Thanks for helping out!
-->
To help with the load of incoming pull requests:
- [x] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/en/development_checklist.html
[manifest-docs]: https://developers.home-assistant.io/docs/en/creating_integration_manifest.html
[quality-scale]: https://developers.home-assistant.io/docs/en/next/integration_quality_scale_index.html
[docs-repository]: https://github.com/home-assistant/home-assistant.io
2 Likes
euggersh
(Eugene Gershtein)
July 17, 2024, 11:50pm
4
Finding this thread a year and a half later, I’m trying to figure out how to get at the “last seen” timestamp for a Tile. I see that the PR was integrated, but the only info I see in HA for any of my Tiles is whether they’re home or not.
I don’t own a tile, so can’t test, but the code says, the sensor should have an attribute last_timestamp
.
Take a look at Developer Tools > States
and look for the sensor name. In the right column you should see the attributes. If not, mark the checkbox “attributes”.
1 Like
Sorry to reopen this after 2 years but did anyone have any examples for creating helper sensors, which uses the tiles last_timestamp attribute and a threshold (e.g. one week) to provide a crude “low battery” sensor?
Update:
I have achieved this via a template helper.
If the last location update “last_timestamp” is older than one week, then assume it’s battery has ran out. This is crude, but works.
It does not help with the issue of the location being reported as “active” even when it’s not been updated for months due to the battery running out.
I then use the Blueprint Low battery level detection & notification for all battery sensors to notify me of any low batteries.
{% if as_timestamp(now()) - as_timestamp(state_attr('device_tracker.bluetooth_speaker', 'last_timestamp')) > 604800 %}
1
{% else %}
0
{% endif %}