Find most frequently updated sensor

had a earlier post on this, but that went in another direction. I was triggered now by Display recently triggered automations recently listing all automations (but easily changed into sensors) updated lastly.

this is a regular jinja template for that:

{% for state in states.sensor| selectattr('last_changed') | sort(attribute='last_changed', reverse=true) -%}
{{ state.last_changed.timestamp() | timestamp_local }} : {{ state.name }}
{% endfor %}

or even sort directly:

{% for state in states.sensor|sort(attribute='last_changed', reverse=true) -%}
{{ state.last_changed.timestamp() | timestamp_local }} : {{ state.name }}

and this the rebuild of Tara’s markdown card:

|D|H|M||Time||Name|
|---:|----:|----:|:--:|:---:|:--:|:----|
{% for state in states.sensor
   |sort(attribute='last_changed', reverse=true) -%}
  {%- set t1 = state.last_changed.timestamp() | timestamp_custom('%H:%M') -%}
  {%- set t = now() - state.last_changed -%}
  {%- set days = t.days if t.days > 0 else ' ' -%}
  {%- set hrs = t.seconds//3600 %}
  {%- set hrs = hrs if hrs > 0 else ' ' -%}
  |{{days}}|{{hrs}}|{{(t.seconds//60)%60}}||{{t1}}||_{{state.name}}_|
{% endfor %}

I’d love to be able to list say the top 10 most updated sensors, (entities for that matter) but not sure how to start to go about that. Hardly possible to add a counter to all entities?

This is one of those situations it might be easier to watch with a human eye to see which sensor pops up most in one of the above templates, than actually creating a code to find it?

thanks for having a look!

The update frequency of the sensor may not be reflected in HA correctly since HA only updates if there is a change.

Maybe you could create SQL sensors from the info here: How to reduce your database size and extend the life of your SD card

Particularly:

Aha, new territory, always nice to explore.
Thanks, will have a look at that.

revisiting that topic explained my deja-vu… We discussed reducing the DB by eliminating recorded items…

which makes me immediately wonder if that sensor would do what I am looking for now, because I don’t record all of these sensors, especially not all the highly frequently updating ones…