Convert float to int within template

Hey,

I currently have an automation, which should change the brightness. My data template creates a float, which is not assignable to the brightness / int.
I tried to use use the integer pipe to convert it but without any success.

- alias: Test
  trigger:
    - platform: state
      entity_id: sensor.temperatur
  action:
  - service: light.turn_on
    entity_id:
      - light.test
    data_template:
      brightness: '{{ (float(states.sensor.kallax_temperatur.state) - float(states.sensor.temperature_158d0002027f49.state)) * float(100) + 220 }}'

Is there any way to convert it?

Thanks in advance

"{{ ((states('sensor.kallax_temperatur')|float - states('sensor.temperature_158d0002027f49')|float) * 100 + 220)|int }}"
2 Likes