I would like a lovelace that will show a list of state changes with newest ones on top.
Sorry if my question is unclear or doesn’t make sense or if I’m using the wrong terminology.
Here’s what I mean: I have all kinds of sensors (temperature, electric use, water use, etc.).
I would like to have a lovelace that shows a list, time ordered with newest at the top, of all new data (changed temperatures for any particular temp sensor, for example).
Do you mean like the Logbook? Especially the Logbook if you don’t filter by any entities?
I’d like to be able to put this on a dashboard too. I suspect the novelty would soon wear of though - probably after causing household members concern about the amount of data they are generating.
{% for x in (states.sensor
|selectattr('attributes.device_class', 'defined')
|selectattr('attributes.device_class', 'eq', 'temperature')
|sort(attribute='last_changed', reverse=true))[0:10] %}
I see in DEVELOPER TOOLS | STATES I can filter by attribute and, for example, use “device_class: Temperature”
Is there a way to list the devices by class? The goal is to be able to see what classes there are and what devices are in each class. I suspect I have a much smaller than average HA setup, but the number of devices is still far too large to manage by human memory.
Certainly there are more elegant ways, but it’s a lazy sunday, so I simply packed my example above in a second loop:
type: markdown
content: |-
{% for x in states.sensor
|selectattr('attributes.device_class', 'defined')
|groupby('attributes.device_class') %}
{% if loop.first %} ### Device Classes: {{loop.length}}{% endif %}
**{{ loop.index }}. Device Class "{{ x[0] }}"**
{% for value in (x[1] |sort(attribute='last_changed', reverse=true))[0:10] %}
{%- if value is defined %}
{%- set name = value.name %}
{%- set state = value.state %}
{%- set time = value.last_changed.timestamp()|timestamp_custom('%H:%M:%S', true, now() ) %}
{{- '• ' ~ name ~ ': ' ~ state ~ ' (' ~ time ~ ')' -}}
{% else %} ERROR
{% endif %}
{% endfor %}
{% endfor %}
Thanks for the reply! Somehow I missed it until coming across this thread during a search.
I was able to move this project forward a little with a template sensor of the alarm system state attribute, and a card I found in HACS that shows the history of a sensor.
Now I’m stuck at trying to filter out some of the unwanted attribute history.