This selects strings that begin with the word light
.
select('match', 'light')
This selects strings that contain the word light
.
select('search', 'light')
So, no, what I suggested won’t select something like switch.kitchen_light
. An entity’s entity_id
is a string that always begins with its domain so using match
is ideal (especially since the result of label_entities
is a simple list of strings).
For your application, you would need to use expand
only if you wanted to extract a list of light
entity_ids in a particular state. Otherwise, select
alone is sufficient.
BTW, the second parameter is actually a regex pattern and not merely a string. For example, you can configure search
to behave like match
using an appropriate regex pattern.
This selects strings that begin with the word light
.
select('search', '^light')
Because it’s a regex pattern, a period character has special meaning. It means “match any character” and not “match a single period character”.
This selects strings that begin with the word light
followed by any character.
select('search', '^light.')
This selects strings that begin with the word light
followed by a period character.
select('search', '^light\.')
This selects strings that begin with the word light
and end with the word kitchen
with any number of other characters between the two words.
select('search', '^light.*kitchen$')