select integration currently supports select_option service call only, while input_select supports input_select.select_next and input_select.select_previous which allow to cycle through select options.
select is not much different from input_select, and pairty of features would be great.
Yes, I totally agree. Iâd like to use this very feature with the WLED integration to select the next preset and was surprised to find out they are treated separately.
I have no clue if it is a complex thing or not but it would be great to have the srvices select_next and select_previous for the newly introduced select entities. Same as what exists for input_select entities.
An example of usage for example would be to change WLED palets or presets with a remote control.
All-in-one script to either select the next or previous option.
select_option:
sequence:
- service: select.select_option
target:
entity_id: '{{ entity }}'
data:
option: >
{% set (next, x, s) = ('n' in direction, state_attr(entity, 'options'), states(entity)) %}
{% set l = x | count - 1 %}
{% set i = x.index(s) + 1 * (iif(next, 1, -1)) if s != 'unknown' else 0 %}
{{ x[i if i <= l else l] if next else x[i if i >= 0 else l] }}
Call script.select_option with direction set to next or previous. Actually, the script only cares if the direction value contains the letter n to handle it as next and anything else is handled as previous.
service: script.select_option
data:
entity: select.whatever
direction: next
NOTE
If you want to make the script more robust, you can include an action condition, prior to the service call, that confirms the supplied entity is a select entity and itâs not unavailable.
Actually nevermind about the previous pull request. Seems someone tried this before and core devs rejected the change indefinitely, seems they donât want it.
Just a guess but I think the rationale is that select is meant to be used by integrations and input_select by users. An integration doesnât need many services to make a selection.
I created a PR long time ago fixing this, but Frenk rejected it.
I really donât get the reasoning why. Select is an array, it has ordering, there is no reason not to have next/previous functionality. Frenkâs argument that some integrations might not expect an order in the selections, like heat/cool/auto for example do not have order. But thatâs not an array, itâs a set, so implement it as such - set not iterable/array iterable.
It was worth a try. Never know if and when they have a change of heart on the matter.
FWIW, it would be nice to have the extra services for select because MQTT Select allows you to define and, most importantly, programmatically re-define the members of the set and have the re-defined set survive a restart (stored on the MQTT broker as a retained message).
In contrast, although you can programmatically re-define an input_selectâs members, the new set doesnât survive a restart (itâs initialized with its original members). However, an input_select is more flexible in scripts and automations due to its additional services whereas select is limited to just one service.