bermuda icon indicating copy to clipboard operation
bermuda copied to clipboard

Add "last seen" sensor for tracked devices with timestamp

Open sdholden28 opened this issue 1 year ago • 4 comments

Describe the solution you'd like I'd like a "last seen" sensor for each tracked device. This sensor would have the last contacted proxy and a timestamp. This would be useful in a "find my device" approach to get an idea of where the item was last known to be and when.

Describe alternatives you've considered I could create this with a triggered template sensor for each tracked device, but it would be nicer if this was an available entity from the integration so it would show up on the device pages and could be enabled/disabled for each device as desired.

sdholden28 avatar May 21 '24 04:05 sdholden28

I'm for this, just need to let it bubble away in my brain a bit to find the implementation I want to go with.

Are you often trying to find things that were left somewhere and then powered off? For me I'm usually looking for things that are still transmitting (so the current sensors work for me 98% of the time) and otherwise I'd click the sensor and look at the history - but if you have a use-case where things are no longer transmitting then I can see the benefit in having a dedicated sensor for it.

I think if I create the sensor as disabled-by-default then it has no impact on folks who don't need it, so that might be way to go (which does mean it only helps if one has already enabled it before needing it!)

agittins avatar May 23 '24 16:05 agittins

Dead battery is the primary use case for me. Left phone in a room, battery died, can't locate it now, etc. Watch, rechargeable wallet tracker, etc are use cases where knowing the "last ping" before the battery died would be helpful, to me. I agree with the "disabled-by-default" approach.

sdholden28 avatar May 23 '24 19:05 sdholden28

Cool, yeah that sounds good. I should be able to get it into the next release, just not sure how soon that will be. Not too long, I hope :-) I'll give you a heads-up once I have it in main as well.

agittins avatar May 24 '24 06:05 agittins

i did this with a template

{% if state_attr('sensor.lina_area', 'area_name') == None or is_state_attr('sensor.lina_area', 'area_name', 'unknown') or is_state_attr('sensor.lina_area', 'area_name', 'unavailable')  -%}
{{ states('sensor.lina_filtered') }}
{%- else %}
{{ state_attr('sensor.lina_area', 'area_name')  }}
{%- endif %}

mogorman avatar Jul 19 '24 18:07 mogorman