Input_select: Select option randomly, and ignore options containing specific word

Testing this in Developers tools works to randomly select an option and exclude the currently selected option, but how to additionally reject all options containing a specific word?

{{ state_attr('input_select.cabinet_tropical_modes_des_lumieres', 'options')
| reject('eq', states('input_select.cabinet_tropical_modes_des_lumieres'))
| list | random }}

does this do what you want?

{{ state_attr('input_select.cabinet_tropical_modes_des_lumieres', 'options')
| reject('eq', states('input_select.cabinet_tropical_modes_des_lumieres'))
| reject('search', 'your_word')
| list | random }}

It does, thanks!
It was the “search” part I got wrong in my testings.

1 Like