Hello,
I need some help to achieve my templating,
I have 3 sensors and I try to obtain the sensor that use the maximum of power.
{{[states.sensor.teleinfo_w1,states.sensor.teleinfo_w2,states.sensor.teleinfo_w3] }}
[<template TemplateState(<state sensor.teleinfo_w1=0; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=teleinfo.W1 @ 2023-08-26T09:07:26.429215+02:00>)>,
<template TemplateState(<state sensor.teleinfo_w2=208; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=teleinfo.W2 @ 2023-08-26T12:17:50.513359+02:00>)>,
<template TemplateState(<state sensor.teleinfo_w3=1251; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=teleinfo.W3 @ 2023-08-26T12:17:50.512851+02:00>)>]
My attempts :
{% for x in [states.sensor.teleinfo_w1,states.sensor.teleinfo_w2,states.sensor.teleinfo_w3] | sort(attribute='state',reverse=true) %}
{{x.entity_id}}{%break%}
{%endfor%}
give : sensor.teleinfo_w2
but with 1251>208 , it’s could be : “sensor.teleinfo_w3” !?!
Any ideas please ?