Calculate maximum color_temp

Hi!

I’m not sure if this is a bug or that I have misunderstood something.

I have some Hue bulbs which I would like to change color_temp on. At first glance I thought that I could use min_mireds and max_mireds and use the value between them to do some percentage calculation and use it as color_temp argument for light.turn_on. E.g:

- id: 'kristallkronan'
  alias: Kristallkronan
  trigger:
  - event_data:
      button_name: flic_mac
      click_type: hold
    event_type: flic_click
    platform: event
  action:
    service: light.turn_on
    data:
      entity_id: light.kristallkronan
    data_template:
      color_temp: >
        {% set entity = 'light.kristallkronan' %}

        {% set min = state_attr(entity, 'min_mireds') %}
        {% set max = state_attr(entity, 'max_mireds') %}
        {% set range = max - min %}


        {% if is_state(entity, "off") %}
          {{ min + (range * 0.50) | int }}
        {% elif state_attr(entity, 'color_temp') == min %}
          {{ min + (range * 0.25) | int }}
        {% elif state_attr(entity, 'color_temp') <= min + (range * 0.25) | int %}
          {{ min + (range * 0.50) | int }}
        {% elif state_attr(entity, 'color_temp') <= min + (range * 0.50) | int %}
          {{ min + (range * 0.75) | int }}
        {% elif state_attr(entity, 'color_temp') <= min + (range * 0.75) | int %}
          {{ max }}
        {% elif state_attr(entity, 'color_temp') == max %}
          {{ min }}
        {% endif %}

But it seems like the maximum color_temp I’m allowed to set is 454 even if the bulb itself tells me that it can handle a max of 500:

min_mireds: 153
max_mireds: 500
brightness: 64
color_temp: 378
friendly_name: Kristallkronan
supported_features: 43

This discrepancy makes my attempt to do this calculation dynamically impossible.

Have I misunderstood the relation between color_temp and max_mireds or does Hue (or HA) lie to me about its capacity?