I have a similar problem, in my case I just need the minimum value for the “cost”.
I found a workaround, but an excessively complicated one.
The way I did it, was to “manually” compare all the values in the data vector and store the position for the minimum in the result.
{% set data = namespace(sensors=[]) %}
{% for cost in states.sensor %}
{%- if "dia" in cost.entity_id.replace("diario", "") and "custo" in cost.entity_id and not "dia_" in cost.entity_id -%}
{% set data.sensors = data.sensors + [cost] %}
{%- endif -%}
{% endfor %}
{% set result = 0 %}
{% for i in range(expand(data.sensors)|map(attribute='state')|list|length) %}
{% if i > 0 and (expand(data.sensors)|map(attribute='state')|list)[i]|float < (expand(data.sensors)|map(attribute='state')|list)[result]|float -%}
{% set result = i %}
{%- endif -%}
{% endfor %}
After that, I just use the result value to return the position of the vector with the attribute I need.