Template of value and if statement

`Hello I have sensor defined as

“{{ ( ( ( (states(‘sensor.Huawei_Power’) | float) | round(2) + (states(‘sensor.licznik_faza123_poweractive_kw’) | float ) | round(2) ) / (states(‘sensor.Huawei_Power’) | float) | round(2) ) ) | round(2) }}”

and it works, but how to add condidion if result >1 then return 1 else return calcualted value ?

{% set x = (( states('sensor.Huawei_Power') | float + states('sensor.licznik_faza123_poweractive_kw') | float ) / states('sensor.Huawei_Power') | float ) | round(2) %}
{{ 1 if x > 1 else x }}
2 Likes

Thank You :slight_smile: