Hi,
Hopefully someone has a pointer for me why the following template does not work anymore in once HA instance (it still works in my second HA instance)
I get the error: TypeError: '<' not supported between instances of 'str' and 'datetime.datetime'
I have tried a lot to make it work again, I think it’s related to some state of “last_triggered” being in a wrong format somehow… But I am unsure.
I use the code in the developer tools:
|D|H|M||Name|
|----:|----:|----:|:--:|:----|
{% for state in states.automation
| selectattr('state', 'ne', 'unavailable')
| selectattr('attributes.last_triggered', 'ne', None)
| selectattr('attributes.last_triggered')
| sort(attribute='attributes.last_triggered', reverse=true) -%}
{%- set t = now() - state.attributes.last_triggered -%}
{%- 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}}||_{{state.name}}_|
{% endfor %}
Any pointers would be very much appreciated!