Assigning a value to a entity dependant on a condition. Use Template if or automation condition

I can’t get my head around “if then else” in HA. It seems so easy in python etc
So I have a calculation based on tomorrows temperature and it used to have a factor from the now defunct blue sky weather integration of % cloud cover. As the only local weather data I can find for cloud is a state ie “Cloudy” or “Sunny” I need the calculation to be divided by 2 if it is Sunny.
So

  -  service: input_number.set_value
         data_template:
           entity_id: input_number.heater_on_time
           value: "{{ ((5.17683 + ((states('input_number.temperature_timer')  | float) * 0.3656716) -  ((states('input_number.temperature_timer')  | float) **2 * 0.04677505)) +0.5) }}"

I need “input_number.heater_on_time” to be half if “input_text.cloud_condition” is “sunny”
It must be something to do with:-

                  {% if is_state('input_text.cloud_condition', 'sunny') %}
                      "Divide by Two"
                    {% else %}
                      "Leave as it is"
                    {% endif %}"

But what goes in the section “Divide by Two” and “Leave it as it is”
or is it using conditions

    condition:
      - condition: or
        conditions:
          - condition: state
            entity_id: input_text.cloud_condition
            state: 'cloudy'
          - condition: state
            entity_id: input_text.cloud_condition
            state: 'sunny'

must be easy but I am struggling.
Thanks for any help or hints. :slight_smile:

                  {% if is_state('input_text.cloud_condition', 'sunny') %}
                    {{ this.state|float(0) / 2 }}
                  {% else %}
                    this.state
                  {% endif %}

Perfect. Thanks for the help. That was the solution. Created another variable to take the value

      -  service: input_number.set_value
         data_template:
           entity_id: input_number.heater_on_time_mod
           value:  "{% if is_state('input_text.cloud_condition', 'sunny') %}
                      {{ states('input_number.heater_on_time') |float(0) / 2 }}
                    {% else %}
                      {{ states('input_number.heater_on_time')}}
                    {% endif %}"