How to fill input_select with the state value from a sensor

I’ve a little problem with “input selectors”. If the state of a entity_sensor is changing, the UI “input select menue” keep always the last settings. How can I set the UI-Menue to the value of the entity_sensor if it is changing. Here my code as a sample:


sensor:
  - platform: template
    sensors:
# Solar Ladung In
      bsb_lan_sol_ladung:
        unique_id: bsb_lan_sol_ladung
        friendly_name: "BSB-LAN Solar Ladung"
        value_template: "{% if states('sensor.bsb_lan_time') is defined and states('sensor.bsb_lan_time') != 'unavailable' %}{{state_attr('sensor.bsb_lan_time', '3822')['desc'] }}{% else %}{{ states('sensor.bsb_lan_sol_ladung') }}{% endif %}"

input_select:
  bsb_lan_sol_ladung:
    name: BSB-LAN Solar Ladung Input
    options:
      - Kein
      - Trinkwasserspeicher
      - Pufferspeicher
    icon: mdi:list-box


automation:

# get value.json ------------------------------------------------------------------------
# Ladung In - auslesen
  - id: bsb_lan_get_sol_ladung
    alias: BSB-LAN Solar Ladung auslesen
    trigger:
      - platform: state
        entity_id: sensor.bsb_lan_sol_ladung
    action:
     - service: input_select.set_options
       target:
         entity_id: input_select.bsb_lan_sol_ladung
         options: "{{ states('sensor.bsb_lan_sol_ladung') }}"
       mode: single

The actual state is “Kein” but it keep:

The set_options service you use in the automation is for setting the allowed options. I guess your automation will work when using input_select.select_option .

Hi elcajon,
thanks for your answer but this won’t work too.


automation:

# get value.json ------------------------------------------------------------------------
# Ladung - auslesen
  - id: bsb_lan_get_sol_ladung
    alias: BSB-LAN Solar Ladung auslesen
    trigger:
      - platform: state
        entity_id: sensor.bsb_lan_sol_ladung
    action:
     - service: input_select.select_option
       target:
         entity_id: input_select.bsb_lan_sol_ladung
         option: "{{ states('sensor.bsb_lan_sol_ladung') }}"
       mode: single

Try it like this

     - service: input_select.select_option
       target:
         entity_id: input_select.bsb_lan_sol_ladung
       data:
         option: "{{ states('sensor.bsb_lan_sol_ladung') }}"

Wow !
Thank you very much.