Input_select and input_number display value vs actual value

I would like the input select to send a different value than the one that is selected.

Like, if the user selects option “A”, then the data put into the variable should be “1”, not “A”. So I’d like to map the selected values to the actual values that will be sent. s

for input_number, I’d like to do math on it before it is sent, such as doubling or halving the value that was selected.

possible?

Yes, with an automation, but where do you intend to store the mapped value? In other words, what do you mean by “variable” here:

I consider the input_select entity to be the “variable”.

I want the user to be able to select something like “banana” and have something like “2” put into the input_select. So I want to define a map like:

banana : 2
apple : 4
chocolate : 6

so then the user can select the name, but then when I look at the value of input_select, I want the number value, not the name.

Not possible.

(At least not using a single input_select.)

You can only have the user select ‘banana’ and 2 be used in an automation or script, or saved to another input number by using an automation.

here’s a more visual example:

Here I let the user select an interface, and then use the config-template-card to change what entity is being graphed. I have to put the actual name of the entity into the input_select, which is kind of a meaningless identifier. I would much rather let the user select from the friendly name instead.


Another one… here I want to do some math on the value the user selects with the slider, before it is ‘committed’. Because I have an automation that picks up when that changes and sends an mqtt msg.

An input_select doesn’t support mapping.

There’s a long-standing Feature Request for it. Feel free to vote for it:

You should be able to map values in that template. Show us what you have.

variables:
  - 'states[''input_select.hours_to_show''].state'
  - 'states[''input_select.select_interface''].state'
entities:
  - input_select.hours_to_show
  - input_select.select_interface
card:
  type: 'custom:mini-graph-card'
  entities:
    - entity: '${vars[1]}'
  hours_to_show: '${vars[0]}'
  points_per_hour: 100
  show:
    state: true
    extrema: true
    points: false
  height: 100
  animate: true
  decimals: 3
  font_size: 80
  line_width: 1

thanks, voted, that looks like exactly what I’m after.

That is possible with an automation. You could not do it without an automation because an input_number has no native means of converting its values; it’s simply a means of setting a float value.

Ugh. JavaScript. I have no idea how to map with that.