Pass select value on set_level of a button

I would like to pass select value not index on set_level of a button.
can I pass it directly from the select or do I have to pass it from a global variable?

select code

  - platform: template
    name: select_text
    id: select_test
    optimistic: true
    options:
      - '10'
      - '20'
      - '30'
      - '40'
      - '90'
    initial_option: '90'
    restore_value: True
    on_value:
      then:
        - lambda: !lambda |-
           auto options = id(select_battery_recharge_voltage_out).traits.get_options();
           id(${id_device}_battery_recharge_voltage_out_idx) = std::distance(options.begin(), std::find(options.begin(), options.end(),x));
 
        - lambda: !lambda |-
            auto state = id(select_battery_recharge_voltage_out).state.c_str();
            ESP_LOGI("main", "Option of my select recharge: %s", state);

button code

button:
  - platform: template
    name: Invio_current_max_charging_current
    id: Send_current_max_charging_current
    icon: "mdi:emoticon-outline"
    on_press:
      then:
        - output.pipsolar.set_level:
            id: current_max_charging_current_out
            value: 10