Is there any way to mark devices or as unavalable or mark them if they did not send messages for some time. I try to find this our with my RFXtrx433 senssors, but would like to know this for other devices and entities also.
# last changed
type: markdown
content: |2-
{% for x in states.sensor
|sort(attribute='last_changed', reverse=true)
%}
<b>
{%- if x %}
{%- set name = x.name %}
{%- set time = x.last_changed.strftime('%T') %}
{{- '• ' ~ name ~ ': ' ~ time -}}
{% else %}
{% endif %}
</b>
{% endfor %}
or
# last updated
type: markdown
content: |2-
{% for x in states.sensor
|sort(attribute='last_updated', reverse=true)
%}
<b>
{%- if x %}
{%- set name = x.name %}
{%- set time = x.last_updated.strftime('%T') %}
{{- '• ' ~ name ~ ': ' ~ time -}}
{% else %}
{% endif %}
</b>
{% endfor %}
The code above can be more specified if you tell the attributes of your sensors you want to monitor.
Thanks a lot. The Display cards are very flexible. Great!
Nice would be to have the current time and subtract this from last seen. And just display the items that did not update for xxx seconds.
Where can I find more information of the scripting you did? Any pointer would be fine.
Google told me that Homeassistant uses jinja as a scripting language for the Display cards. Any other pointers on documentation to script? Do I have to import datetime to use datetime for the current time?