Switch fuction to check state of a dropdown

Hi everyone,

I am trying to set up the climate settings for my ioniq 5 with dropdowns and then send the start climate call according to the set dropdowns

sadly they have a strange logic.
For each seat you can choose
off, on, low cooling, mid cooling, high cooling, low heat, mid…)
Each of those values is a number from 0 to 9.
Then if you choose steeringwheel heat and defrost the climate filed in the integration is for example number 4. If its only steerign it will be 3

What I am trying to figure out is how I can code this using somethign like switch VARHeating { 0: xyz; 1: abc etc.}

The idea is to set all the dropdowns and then run an automation that will calculate the values and then starts the start climate function.

The integration is called hyundai-bluelink-integration

Any feedback woudl be awesome.

thank you!

You can set up variable mappings in a script either directly in the YAML or within a template. In both cases you would use templating to render the output for your service call.

I couldn’t find an integration by that exact name. If you need further help you may want to link to the repo of the integration you are actually using.

thank you for the links. I tried it within the automation but not with great success.

Whenever I try to get the value its null.
Must be doing it wrong.

the integration is this one: GitHub - Hyundai-Kia-Connect/kia_uvo: A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
Each car is a bit different. I have an Ioniq 5 2023

Post the automation you tried and describe how you tested it.

Hi Didgeridew,

the problem is I can’t find the way on how to check a dropdown at all.
I googled and there is no apparent way to me.

The idea was to do something like

switch (dropdownValueSeatLeftFront)
{
 1:  if (dropdownValueDefrost == 1) { set heating value to 2 } else { set ehating alue to 1 }


 2:  { additional logic...}

default: 
}

What do you mean by “dropdown”? A Dropdown/Input Select Helper? A custom card that provides a dropdown menu? Something else entirely?

There are more than 2000 integrations, hundreds of custom cards, and likely 100,000 devices that work with Home Assistant… Please follow the Community Guidelines: How to Ask a Good Question. There are a number of users on here that can likely help if you provide details of what you are using instead of vague posts. For example, share an example of the service call you will be using.

Assuming by “dropdown” you mean an Input select helper… there are two main ways to handle switch cases in automations. The most basic way is to use a Choose action with conditions that check your input_select entity’s state. But this becomes unwieldy when dealing with multiple variables. For that you use, the aforementioned, templating.

action:
  - variables:
      dropdown_value_seat_left_front:
        heating_value: "{{ 2 if states('input_select.dropdown_value_left_defrost') == '1') else 1}}"
        type: |
          {% set mapper = { "off": 0, "on": 1, "low cooling": 2, "mid cooling": 3, 
          "high cooling": 4, "low heat": 5, "mid heat": 6, "high heat": 7 } %}
          {{ mapper.get( states('input_select.dropdown_climate_left_front')) }}
  - service: hyundai.example
    data:
      example_1: "{{ dropdown_value_seat_left_front.heating_value }}"
      example_2: "{{ dropdown_value_seat_left_front.type }}"