Trying to change Color Temp based on sun angle or time

Hello,
I am new to HA and have been using the guides and forums to build my automation. Unfortunately, I am now stuck trying to get the following automation to work. It is supposed to change the color temperature of my LIFX lights based on the sun angle or time. Any ideas why it will not trigger at all?

- id: 'workweekeveninglightskelvinadjust'
  alias: Workweek Eve Lights Kelvin adjust
  trigger:
  - platform: time
    minutes: '/5'
    seconds: 00
  condition:
  - condition: state
    entity_id: group.stube
    state: 'on'
  - condition: numeric_state
    entity_id: sun.sun
    below: 9.5
    above: -30.0
  - condition: time
    after: '15:15:00'
    before: '22:15:00'
    weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
  action:
    service: light.lifx_set_state
    data:
      entity_id: group.stube
      transition: 900
    data_template:
      kelvin: >
        {% if state_attr('sun.sun', 'elevation') | float | round(0) >= 9 and states('sensor.time') <= '18:30' %}
          5000
        {% elif state_attr('sun.sun', 'elevation') | float | round(0) >= 6 and states('sensor.time') <= '19:00' %}
          4500
        {% elif state_attr('sun.sun', 'elevation') | float | round(0) >= 3 and states('sensor.time') <= '19:30' %}
          4000
        {% elif state_attr('sun.sun', 'elevation') | float | round(0) >= 0 and states('sensor.time') <= '20:00' %}
          3500
        {% elif state_attr('sun.sun', 'elevation') | float | round(0) >= -3 and states('sensor.time') <= '20:30' %}
          3200
        {% elif state_attr('sun.sun', 'elevation') | float | round(0) >= -6 and states('sensor.time') <= '21:00' %}
          3000
        {% elif state_attr('sun.sun', 'elevation') | float | round(0) >= -9 and states('sensor.time') <= '21:30' %}
          2750
        {% elif state_attr('sun.sun', 'elevation') | float | round(0) >= -12 and states('sensor.time') <= '22:00' %}
          2500
        {% else %}
          2500
        {% endif %}

Any ideas? Thanks for help.
Cheers

The state of sun.sun will be either ‘above_horizon’ or ‘below_horizon’. It does not have a value that can be interpreted as a number, so this condition as written will always evaluate to false. I think you want sun.sun’s elevation attribute. If so, then try this instead:

  - condition: numeric_state
    entity_id: sun.sun
    value_template: "{{ state.attributes.elevation }}"
    below: 9.5
    above: -30.0

I do not want to use Flux because it is not what I am looking for.

Thanks I will try this.