Sensor value calculation based on state from another

Hi forum,
I have a temperature sensor which I would like to do some initial changes to depending on the state from another sensor.

  value_template: >
   {% if states('sensor.yr_temperature') | float > 20 %}
     {% states('sensor.office.attributes.temperature') |multiply(1.08) | round(2) %}
   {% else %}
     {% states('sensor.office.attributes.temperature') |multiply(1.14) | round(2) %}
   {% endif %}

I’m getting a Ninja TemplateSyntaxError, but where exactly is the error in my lines?

Thanks! :sunglasses:

Try this:

  value_template: >
   {% if states('sensor.yr_temperature') | float > 20 %}
     {{ state_attr('sensor.office', 'temperature') |multiply(1.08) | round(2) }}
   {% else %}
     {{ state_attr('sensor.office', 'temperature') |multiply(1.14) | round(2) }}
   {% endif %}
1 Like

Thank you pnbruckner! That was it! So close then… And thank you for the quick reply! :raised_hands:t4::raised_hands:t4:

1 Like