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 %}