Yeelight changing kelvin

Hi,

I am pretty new to automation templating and I try to switch kelvin, every time I press a button.
I tested the following with developer tools and it always returns the value I would like to have:

  {% if states.light.living_room.attributes.color_temp < 225 %}
   225
  {% elif states.light.living_room.attributes.color_temp < 300 %}
   300
  {% elif states.light.living_room.attributes.color_temp < 370 %}
   370
  {% else %}
   153
  {% endif %}

I also tried setting “color_temp” with developer tools > states and tested it with the service light.turn_on and exactly this lamp, and it worked. (Cause I heard sometimes not all features are available for a product)

But when I combine it to an automation, it does not work anymore:

data:
  color_temp: |
  {% if states.light.living_room.attributes.color_temp < 225 %}
   225
  {% elif states.light.living_room.attributes.color_temp < 300 %}
   300
  {% elif states.light.living_room.attributes.color_temp < 370 %}
   370
  {% else %}
   153
  {% endif %}
entity_id: light.living_room
service: light.turn_on

If I just set color_temp directly, e.g. 160 or 370, it works, so the automation does trigger correctly.

I also tried changing the values to int, but when I try this at the developer tools, it says it would have expected int as return type, what sounds weird:

  {% if states.light.living_room.attributes.color_temp < 225 %}
   {{225|int}}
  {% elif states.light.living_room.attributes.color_temp < 300 %}
   {{300|int}}
  {% elif states.light.living_room.attributes.color_temp < 370 %}
   {{370|int}}
  {% else %}
   {{153|int}}
  {% endif %}

Anybody has an idea on this?

Thank you,
Steeveno