Input_select not able to use templating for initial value

Hi All,
Just seeking clarification that the initial value in a input_select cannot use jinja2 templating for a response.

I have a input_select:

ground_hvac_climate_mode:
  name: Ground HVAC Climate Mode
  options:
    - 'Off'
    - Heat
    - Cool
  initial: Heat
  icon: mdi:sun-snowflake-variant

When I use the input select as:

ground_hvac_climate_mode:
  name: Ground HVAC Climate Mode
  options:
    - 'Off'
    - Heat
    - Cool
  initial: |
    {% for now().month in [4,5,6,7,8,9,10] %}
      Heat
    {% else %}
      "Off"
    {% endif %}
  icon: mdi:sun-snowflake-variant

then the system generates an error
Logger: homeassistant.config
Source: config.py:942
First occurred: 10:57:27 (1 occurrences)
Last logged: 10:57:27

Invalid config for ‘input_select’ at input_selects/hvac.yaml, line 9: initial state {% if now().month in [4,5,6,7,8,9,10] %} Heat {% else %} “Off” {% endif %} is not part of the options: Off,Heat,Cool for dictionary value ‘input_select->ground_hvac_climate_mode’, got {‘name’: ‘Ground HVAC Climate Mode’, ‘options’: [‘Off’, ‘Heat’, ‘Cool’], ‘initial’: ‘{% if now().month in [4,5,6,7,8,9,10] %}\n Heat\n{% else %}\n “Off”\n{% endif %}\n’, ‘icon’: ‘mdi:sun-snowflake-variant’}, please check the docs at Input select - Home Assistant

So no jinja templating for initial value is allowed? Am I doing something wrong?

Not really sure why you would want this, but if you want to use templating, you need to use a Template Select. However, template selects don’t have an initial configuration variable, their initial is the first option in the options variable’s list, so you would do something like:

...
  options: |
    {% for now().month in [4,5,6,7,8,9,10] %}
      {{ ["Heat", "Cool", "Off"] }}
    {% else %}
      {{ ["Off", "Heat", "Cool"] }}
    {% endif %}
...

HA Docs - Template - Select

Thanks, Will have a look to see if that is a solution for me.

The documentation shows initial takes a “map”, so it does not support templating. Why would you want to template the initial value anyway since it only ever gets used once when the entity is first created. It sounds more like you want an automation to change the value once a month.

However, this will likely cause it to reset a minute after you manually change it. For example, if you manually select “Cool”, then at the next minute the automation will run and change it back to Heat/Off depending on the month (now() will cause it to run every minute). So this begs the question - what is it you’re wanting to achieve?