Closed jacauc closed 1 year ago
Has this project been abandoned?
attribute: last_tripped_time numeric: true
Is the "last_tripped_time" attribute a string? Then why do you sort it as a number? To be sorted properly, the value must be a timestamp. If it is a string - then you will have to convert it to a timestamp first, then sort by this numeric value. This should be done by using a "template" filter.
Good catch... Can the templating be done dynamically in the lovelace card? The list of entities included is dynamic based on the include filter.
I tried something like this, but doesn't seem to do the trick. Any guidance would be appreciated
attribute: "{{ 'last_tripped_time' | as_datetime }}"
attribute: "{{ 'last_tripped_time' | as_datetime }}"
Templates are NOT supported for options like "state", "attribute" etc. Use the "template" option which defines what to include, what to exclude. Check for examples in the dedicated auto-entities Community thread.
I tried like this, has no effect. It seems the template option is only for filters, not for sorting. I'm guessing this is not possible to sort by a templated attribute then.
meh, honestly not that important to me, didn't realize it would be as complicated to achieve. Closing the issue
type: custom:auto-entities
card:
type: entities
title: Last 3 Movements
show_header_toggle: true
state_color: true
filter:
include:
- domain: binary_sensor
attributes:
device_class: motion
sort:
template: "{{ 'last_tripped_time' | as_datetime }}"
method: attribute
attribute: last_tripped_time
count: 30
reverse: false
ignore_case: true
numeric: true
only for filters, not for sorting.
sorting is done inside filtering
I have envisalink entities that I would like to sort by an attribute with datetime format, but it does not seem to sort correctly. I'm guessing the card does not parse the datetime value correctly before sorting and maybe sorts by string value instead?
Here is my code: