Numeric input_select state with human-readable labels?

What you want is possible, but requires work.

You’ll need to have the following code in all your templates:

Automations where you aren’t using trigger object (trigger.to_state… etc)

{% set option_number = state_attr('input_select.xxx','options').index(states('input_select.xxx')) %}

Automations where you are using the trigger object

{% set option_number = state_attr(trigger.entity_id,'options').index(states(trigger.entity_id)) %}

The output of these templates is an index position of your input_selection. Remember list indexes start at zero.


Example

These are the options in your input_select.xxx

  • Item A
  • Item B
  • Item C
  • Item D

If your input_select.xxx is set to Item A, your output_number from the template contain a value of 0 after executing the template line supplied above.

If your input_select.xxx is set to Item B, your output_number from the template contain a value of 1 after executing the template line supplied above.

If your input_select.xxx is set to Item C, your output_number from the template contain a value of 2 after executing the template line supplied above.

If your input_select.xxx is set to Item D, your output_number from the template contain a value of 3 after executing the template line supplied above.

So, pretty much your selection option order is what drives what number you get from that template line.

4 Likes