Select helper with label and values

Sometime you need use a selector for a service that use certain values “not human”, so, you can create a selector with ugly labels or pretty label and remaped with map or if/else the human value to valid value, that is very boring and add complexity to automation

Example:


- input_select:
    oven_program:
      name: Oven Program
      options:
      - label: Pizza
         value: 12
      - label: Potates
        value: 15
    initial: 12

That would make a lot of mapping templates redundant.

(Your indentation on the second value is one space too many though).

This is technically already implemented, however, not exposed at this point. :+1:
Good suggestion

8 Likes

That sounds interesting :slight_smile:

Sounds like this nearly three year old Feature Request may soon be fulfilled. :+1:

2 Likes

exposssssssse it

8 Likes

My initial thought was that this already existed, but after reading through the 2019 post, I realized that I am actually doing it using the more complex (and harder to read) templating methodology. This new way has a vote from me!

Would be awesome also when you want to have all values in English but also like to have translated friendly names.

1 Like

Well hey I knew English wasn’t a “romantic” language but I didn’t think it was actually “unfriendly” :laughing:

Translations in general need to be available in the backend somehow (even in templates). It’s a point of contention for me.

1 Like

Any idea if, and when, this will be released?

1 Like

It’s not as easy as it should be, but you can assign text to values ​​or vice versa.

-mqtt:
  - select:
      unique_id: 'Set Warmwater Mode'
      name: 'Set Warmwater Mode'
      command_topic: 'stat/logamatic/Command'
      retain: true
      options:
        - 'Off'
        - 'On'
        - 'Automatic'
      state_topic: 'stat/logamatic/WW/Mode'
      value_template: >-
        {% set values = {'0':Off', '1':'On', '2':'Automatic'} %}
        {{ values[value] if value in values.keys() else 'Off' }}

      command_template: >-
        WW_MODE:{% set values = {'Off':0, 'On':1,  'Automatic':2} %}
        {{ values[value] if value in values.keys() else 0 }}
3 Likes

Would still be something very usefull!