I have multiple sensors in my home reporting the power consumption for diverse appliances.
I would like to see in the fronted which appliance consumes the most (in an instant of time).
I create a template showing all the sensors I am interested in. I would like to sort them from large to small and retrieve only the first/last values, but the sort does not work properly.
This is what I have up to now and the result from the template.
Am I doing something wrong?
Thanks!
Template
{% for state in states.sensor | sort(attribute="state") | reverse %}
{%- if state.attributes.unit_of_measurement == 'W' %}
{{ state.attributes.friendly_name }}: {{state.state}} {{- state.attributes.unit_of_measurement}}
{% endif -%}
{%- endfor -%}
Result
Desktop: 73.7W
Boiler: 6.5W
TV: 4.1W
Router area: 27.1W
Other: 25.04W
Washing machine: 1.8W
Oven: 0.9W
Fridge: 0.9W
Dishwasher: 0.9W
Laptop: 0.5W