Calculation in a template helper

I am using a template helper to calculate the relative temperature based on the temperature, the wind and humidity:

{% set temperature1 = states('sensor.temperatur_farstu_air_temperature_8') | float(0) %}
{% set humidity1 = states('sensor.are_humidity') | float(0) %}
{% set windspeedmps1 = states('sensor.arewindspeed_mpers') | float(0) %}
{% set wvp1 = (humidity1/100) * 6.105 * e**((17.27*temperature1) / (237.7 + temperature1))%}
{{ (temperature1 + 0.33 * wvp1 - 0.70 * windspeedmps1 - 4.00)|round }}

What I would like to to is to use a condition for using one or another entity on the first row in the variable “temperature1”. Something like
if bypass=0 then temperature1 = entity1
if bypass=1 then temperature1 = entity2

Does anybody knows if this is possible and in this case what I should write in my template helper?

What is bypass? Where is this coming from?

Bypass is a helper with the type boolean and it is triggered from a dashboard:
Skärmbild 2025-02-12 130513

{% set temperature1 = states('sensor.entity_2') | float(0) if is_state('input_boolean.bypass','on') else states('sensor.entity_1')  | float(0) %}

Or a more condensed version…:

{% set temperature1 = states('sensor.entity_' ~ ['1', '2'][is_state('input_boolean.bypass', 'on')]) | float(0) %}
2 Likes